diff options
author | Matt Hoosier <matt.hoosier@garmin.com> | 2020-05-27 15:29:00 -0500 |
---|---|---|
committer | Matt Hoosier <matt.hoosier@garmin.com> | 2020-05-28 14:08:42 -0500 |
commit | 554f3f0231c432dea740e56d6a51a15983c93310 (patch) | |
tree | 5b8a7e630944ef168de903afc33c7fbe20ec083d /kms++/src | |
parent | a9480f87902840388497ff85062e73381317626f (diff) |
card: add factory function for selecting card by name
Uses drmOpen() to do the heavy lifting.
Diffstat (limited to 'kms++/src')
-rw-r--r-- | kms++/src/card.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
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"); |