summaryrefslogtreecommitdiff
path: root/kms++/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-12-01 21:45:49 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-08-06 01:59:56 +0300
commit740c330f4c8ee2e0eb1b5b3dfa44f33ac7a68c7a (patch)
tree8ff6addd96c45d69c318da527f40e307a550e2d1 /kms++/src
parent38bee3092f2d477f1baebfcae464f888d3d04bbe (diff)
card: Add a method to retrieve the device minor
The device minor number is needed to access the debugfs directory corresponding to the device. Make it available to users through a get_minor() method on the Card object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'kms++/src')
-rw-r--r--kms++/src/card.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp
index 527aca6..3a7ab70 100644
--- a/kms++/src/card.cpp
+++ b/kms++/src/card.cpp
@@ -9,6 +9,10 @@
#include <algorithm>
#include <glob.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <sys/types.h>
+
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -183,8 +187,15 @@ void Card::setup()
m_version.desc = string(ver->desc, ver->desc_len);
drmFreeVersion(ver);
+ struct stat stats;
int r;
+ r = fstat(m_fd, &stats);
+ if (r < 0)
+ throw invalid_argument("Can't stat device (" + string(strerror(errno)) + ")");
+
+ m_minor = minor(stats.st_dev);
+
r = drmSetMaster(m_fd);
m_is_master = r == 0;