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>main
parent
798022b61c
commit
0caf58a6cb
|
@ -2,6 +2,7 @@ AM_CFLAGS = \
|
||||||
$(WARN_CFLAGS)\
|
$(WARN_CFLAGS)\
|
||||||
-I$(top_srcdir)/include/drm \
|
-I$(top_srcdir)/include/drm \
|
||||||
-I$(top_srcdir)/libkms/ \
|
-I$(top_srcdir)/libkms/ \
|
||||||
|
-I$(top_srcdir)/tests/ \
|
||||||
-I$(top_srcdir)
|
-I$(top_srcdir)
|
||||||
|
|
||||||
if HAVE_INSTALL_TESTS
|
if HAVE_INSTALL_TESTS
|
||||||
|
@ -17,7 +18,8 @@ kmstest_SOURCES = \
|
||||||
|
|
||||||
kmstest_LDADD = \
|
kmstest_LDADD = \
|
||||||
$(top_builddir)/libdrm.la \
|
$(top_builddir)/libdrm.la \
|
||||||
$(top_builddir)/libkms/libkms.la
|
$(top_builddir)/libkms/libkms.la \
|
||||||
|
$(top_builddir)/tests/util/libutil.la
|
||||||
|
|
||||||
run: kmstest
|
run: kmstest
|
||||||
./kmstest
|
./kmstest
|
||||||
|
|
|
@ -25,12 +25,14 @@
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "xf86drm.h"
|
#include "xf86drm.h"
|
||||||
#include "libkms.h"
|
#include "libkms.h"
|
||||||
|
|
||||||
|
#include "util/kms.h"
|
||||||
|
|
||||||
#define CHECK_RET_RETURN(ret, str) \
|
#define CHECK_RET_RETURN(ret, str) \
|
||||||
if (ret < 0) { \
|
if (ret < 0) { \
|
||||||
printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \
|
printf("%s: %s (%s)\n", __func__, str, strerror(-ret)); \
|
||||||
|
@ -56,26 +58,37 @@ static int test_bo(struct kms_driver *kms)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *drivers[] = {
|
static void usage(const char *program)
|
||||||
"i915",
|
{
|
||||||
"radeon",
|
fprintf(stderr, "Usage: %s [options]\n", program);
|
||||||
"nouveau",
|
fprintf(stderr, "\n");
|
||||||
"vmwgfx",
|
fprintf(stderr, " -D DEVICE open the given device\n");
|
||||||
"exynos",
|
fprintf(stderr, " -M MODULE open the given module\n");
|
||||||
"amdgpu",
|
}
|
||||||
"imx-drm",
|
|
||||||
"rockchip",
|
|
||||||
"atmel-hlcdc",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
static const char optstr[] = "D:M:";
|
||||||
struct kms_driver *kms;
|
struct kms_driver *kms;
|
||||||
int ret, fd, i;
|
int c, fd, ret;
|
||||||
|
char *device = NULL;
|
||||||
|
char *module = NULL;
|
||||||
|
|
||||||
for (i = 0, fd = -1; fd < 0 && drivers[i]; i++)
|
while ((c = getopt(argc, argv, optstr)) != -1) {
|
||||||
fd = drmOpen(drivers[i], NULL);
|
switch (c) {
|
||||||
|
case 'D':
|
||||||
|
device = optarg;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
module = optarg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage(argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = util_open(device, module);
|
||||||
CHECK_RET_RETURN(fd, "Could not open device");
|
CHECK_RET_RETURN(fd, "Could not open device");
|
||||||
|
|
||||||
ret = kms_create(fd, &kms);
|
ret = kms_create(fd, &kms);
|
||||||
|
|
Loading…
Reference in New Issue