Skip to contentSkip to conversation

modetest: Try and open device using drmOpenDevice first

PATCH New Marek Vasut 1 participant 1 message May 22, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modetest: Try and open device using drmOpenDevice first

This way, it is possible to use modetest -D to specify a card in /dev/dri/cardN which is esp. useful on systems which have multiple cards, with identical modules and where it is otherwise impossible to discern the different cards via drmOpen(). One such example is i.MX8M Plus, which has three such cards, one for DSI, one for LVDS, and one for HDMI.

---
 tests/util/kms.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tests/util/kms.c +11 -0
index 34a84180..31087522 100644
@@ -38,6 +38,7 @@
  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -142,6 +143,16 @@ int util_open(const char *device, const char *module)
 	} else {
 		unsigned int i;
 
+		printf("trying to open device '%s'...", device);
+
+		fd = open(device, O_RDWR | O_CLOEXEC);
+		if (fd < 0) {
+			printf("failed\n");
+		} else {
+			printf("done\n");
+			return fd;
+		}
+
 		for (i = 0; i < ARRAY_SIZE(modules); i++) {
 			printf("trying to open device '%s'...", modules[i]);
 
Signature · 1 line
2.39.2