mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 08:10:11 +01:00
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>
This commit is contained in:
parent
6223481b8d
commit
b020b02f84
2 changed files with 20 additions and 21 deletions
|
|
@ -15,4 +15,5 @@ endif
|
||||||
vbltest_SOURCES = \
|
vbltest_SOURCES = \
|
||||||
vbltest.c
|
vbltest.c
|
||||||
vbltest_LDADD = \
|
vbltest_LDADD = \
|
||||||
$(top_builddir)/libdrm.la
|
$(top_builddir)/libdrm.la \
|
||||||
|
$(top_builddir)/tests/util/libutil.la
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,11 @@
|
||||||
#include "xf86drmMode.h"
|
#include "xf86drmMode.h"
|
||||||
|
|
||||||
#include "util/common.h"
|
#include "util/common.h"
|
||||||
|
#include "util/kms.h"
|
||||||
|
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
static char optstr[] = "s";
|
static char optstr[] = "D:M:s";
|
||||||
|
|
||||||
int secondary = 0;
|
int secondary = 0;
|
||||||
|
|
||||||
|
|
@ -97,16 +98,19 @@ static void vblank_handler(int fd, unsigned int frame, unsigned int sec,
|
||||||
|
|
||||||
static void usage(char *name)
|
static void usage(char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-s]\n", name);
|
fprintf(stderr, "usage: %s [-DMs]\n", name);
|
||||||
fprintf(stderr, "\t-s\tuse secondary pipe\n");
|
fprintf(stderr, "\n");
|
||||||
|
fprintf(stderr, "options:\n");
|
||||||
|
fprintf(stderr, " -D DEVICE open the given device\n");
|
||||||
|
fprintf(stderr, " -M MODULE open the given module\n");
|
||||||
|
fprintf(stderr, " -s use secondary pipe\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
unsigned i;
|
const char *device = NULL, *module = NULL;
|
||||||
int c, fd, ret;
|
int c, fd, ret;
|
||||||
const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "exynos", "omapdrm", "tilcdc", "msm", "tegra", "imx-drm" , "rockchip" };
|
|
||||||
drmVBlank vbl;
|
drmVBlank vbl;
|
||||||
drmEventContext evctx;
|
drmEventContext evctx;
|
||||||
struct vbl_info handler_info;
|
struct vbl_info handler_info;
|
||||||
|
|
@ -114,6 +118,12 @@ int main(int argc, char **argv)
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
while ((c = getopt(argc, argv, optstr)) != -1) {
|
while ((c = getopt(argc, argv, optstr)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 'D':
|
||||||
|
device = optarg;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
module = optarg;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
secondary = 1;
|
secondary = 1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -123,21 +133,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(modules); i++) {
|
fd = util_open(module, device);
|
||||||
printf("trying to load module %s...", modules[i]);
|
if (fd < 0)
|
||||||
fd = drmOpen(modules[i], NULL);
|
return 1;
|
||||||
if (fd < 0) {
|
|
||||||
printf("failed.\n");
|
|
||||||
} else {
|
|
||||||
printf("success.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == ARRAY_SIZE(modules)) {
|
|
||||||
fprintf(stderr, "failed to load any modules, aborting.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get current count first */
|
/* Get current count first */
|
||||||
vbl.request.type = DRM_VBLANK_RELATIVE;
|
vbl.request.type = DRM_VBLANK_RELATIVE;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue