summaryrefslogtreecommitdiff
path: root/kms++
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-08-06 05:17:59 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-08-10 09:44:27 +0300
commit76b6ef85cded5e576dca6cd2840aeb0da9512287 (patch)
tree03761b1ceefea21bf94634ccfe99e514e2f4e0d4 /kms++
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 dev_minor() method on the Card object. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++')
-rw-r--r--kms++/inc/kms++/card.h2
-rw-r--r--kms++/src/card.cpp11
2 files changed, 13 insertions, 0 deletions
diff --git a/kms++/inc/kms++/card.h b/kms++/inc/kms++/card.h
index 5c1cf7c..8af0969 100644
--- a/kms++/inc/kms++/card.h
+++ b/kms++/inc/kms++/card.h
@@ -35,6 +35,7 @@ public:
Card& operator=(const Card& other) = delete;
int fd() const { return m_fd; }
+ unsigned int dev_minor() const { return m_minor; }
void drop_master();
@@ -84,6 +85,7 @@ private:
std::vector<Framebuffer*> m_framebuffers;
int m_fd;
+ unsigned int m_minor;
bool m_is_master;
bool m_has_atomic;
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;