[PATCH 1/2] modetest: add a -D option to specify a device to be used

Ilia Mirkin imirkin at alum.mit.edu
Sat Sep 7 18:36:01 PDT 2013


This is helpful for differentiating between multiple devices that use
the same module.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 tests/modetest/modetest.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index f0ed56b..9d6e279 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1303,7 +1303,7 @@ static int parse_property(struct property_arg *p, const char *arg)
 
 static void usage(char *name)
 {
-	fprintf(stderr, "usage: %s [-cdefMmPpsvw]\n", name);
+	fprintf(stderr, "usage: %s [-cDdefMPpsvw]\n", name);
 
 	fprintf(stderr, "\n Query options:\n\n");
 	fprintf(stderr, "\t-c\tlist connectors\n");
@@ -1320,6 +1320,7 @@ static void usage(char *name)
 	fprintf(stderr, "\n Generic options:\n\n");
 	fprintf(stderr, "\t-d\tdrop master after mode set\n");
 	fprintf(stderr, "\t-M module\tuse the given driver\n");
+	fprintf(stderr, "\t-D device\tuse the given device\n");
 
 	fprintf(stderr, "\n\tDefault is to dump all info.\n");
 	exit(0);
@@ -1346,7 +1347,7 @@ static int page_flipping_supported(void)
 #endif
 }
 
-static char optstr[] = "cdefM:P:ps:vw:";
+static char optstr[] = "cdD:efM:P:ps:vw:";
 
 int main(int argc, char **argv)
 {
@@ -1357,6 +1358,7 @@ int main(int argc, char **argv)
 	int drop_master = 0;
 	int test_vsync = 0;
 	const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "tilcdc", "msm" };
+	char *device = NULL;
 	char *module = NULL;
 	unsigned int i;
 	int count = 0, plane_count = 0;
@@ -1377,6 +1379,10 @@ int main(int argc, char **argv)
 		case 'c':
 			connectors = 1;
 			break;
+		case 'D':
+			device = optarg;
+			args--;
+			break;
 		case 'd':
 			drop_master = 1;
 			break;
@@ -1447,7 +1453,7 @@ int main(int argc, char **argv)
 		encoders = connectors = crtcs = planes = framebuffers = 1;
 
 	if (module) {
-		dev.fd = drmOpen(module, NULL);
+		dev.fd = drmOpen(module, device);
 		if (dev.fd < 0) {
 			fprintf(stderr, "failed to open device '%s'.\n", module);
 			return 1;
@@ -1455,7 +1461,7 @@ int main(int argc, char **argv)
 	} else {
 		for (i = 0; i < ARRAY_SIZE(modules); i++) {
 			printf("trying to open device '%s'...", modules[i]);
-			dev.fd = drmOpen(modules[i], NULL);
+			dev.fd = drmOpen(modules[i], device);
 			if (dev.fd < 0) {
 				printf("failed.\n");
 			} else {
-- 
1.8.1.5



More information about the dri-devel mailing list