diff options
Diffstat (limited to 'kms++')
-rw-r--r-- | kms++/inc/kms++/card.h | 2 | ||||
-rw-r--r-- | kms++/src/card.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/kms++/inc/kms++/card.h b/kms++/inc/kms++/card.h index 9ca06b2..5c1cf7c 100644 --- a/kms++/inc/kms++/card.h +++ b/kms++/inc/kms++/card.h @@ -24,6 +24,8 @@ class Card { friend class Framebuffer; public: + static std::unique_ptr<Card> open_named_card(const std::string& name); + Card(const std::string& dev_path = ""); Card(const std::string& driver, uint32_t idx); Card(int fd, bool take_ownership); diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp index 062645a..527aca6 100644 --- a/kms++/src/card.cpp +++ b/kms++/src/card.cpp @@ -104,6 +104,16 @@ static int open_device_by_driver(string name, uint32_t idx) throw invalid_argument("Failed to find a DRM device " + name + ":" + to_string(idx)); } +std::unique_ptr<Card> Card::open_named_card(const std::string& name) +{ + int fd = drmOpen(name.c_str(), 0); + + if (fd < 0) + throw invalid_argument(string(strerror(errno)) + " opening card \"" + name + "\""); + + return std::unique_ptr<Card>(new Card(fd, true)); +} + Card::Card(const std::string& dev_path) { const char* drv_p = getenv("KMSXX_DRIVER"); |