diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2019-01-11 11:47:38 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2019-01-14 09:27:28 +0200 |
commit | 588570115ff515fb2152e5ae1cd34fedbf5937c2 (patch) | |
tree | fa8411f2ab66a3ca9e23247ee53f782985c8e2bf | |
parent | f63f1b1a16269ddcce75a61d540429fe3d41cfc8 (diff) |
card: don't throw when no resources
Allow opening DRM cards without any resources.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r-- | kms++/src/card.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp index 5d6a597..3b3e2c1 100644 --- a/kms++/src/card.cpp +++ b/kms++/src/card.cpp @@ -147,43 +147,43 @@ void Card::setup() throw invalid_argument("Dumb buffers not available"); auto res = drmModeGetResources(m_fd); - if (!res) - throw invalid_argument("Can't get card resources"); - - for (int i = 0; i < res->count_connectors; ++i) { - uint32_t id = res->connectors[i]; - auto ob = new Connector(*this, id, i); - m_obmap[id] = ob; - m_connectors.push_back(ob); - } + if (res) { + for (int i = 0; i < res->count_connectors; ++i) { + uint32_t id = res->connectors[i]; + auto ob = new Connector(*this, id, i); + m_obmap[id] = ob; + m_connectors.push_back(ob); + } - for (int i = 0; i < res->count_crtcs; ++i) { - uint32_t id = res->crtcs[i]; - auto ob = new Crtc(*this, id, i); - m_obmap[id] = ob; - m_crtcs.push_back(ob); - } + for (int i = 0; i < res->count_crtcs; ++i) { + uint32_t id = res->crtcs[i]; + auto ob = new Crtc(*this, id, i); + m_obmap[id] = ob; + m_crtcs.push_back(ob); + } - for (int i = 0; i < res->count_encoders; ++i) { - uint32_t id = res->encoders[i]; - auto ob = new Encoder(*this, id, i); - m_obmap[id] = ob; - m_encoders.push_back(ob); - } + for (int i = 0; i < res->count_encoders; ++i) { + uint32_t id = res->encoders[i]; + auto ob = new Encoder(*this, id, i); + m_obmap[id] = ob; + m_encoders.push_back(ob); + } - drmModeFreeResources(res); + drmModeFreeResources(res); - auto planeRes = drmModeGetPlaneResources(m_fd); + auto planeRes = drmModeGetPlaneResources(m_fd); + if (planeRes) { + for (uint i = 0; i < planeRes->count_planes; ++i) { + uint32_t id = planeRes->planes[i]; + auto ob = new Plane(*this, id, i); + m_obmap[id] = ob; + m_planes.push_back(ob); + } - for (uint i = 0; i < planeRes->count_planes; ++i) { - uint32_t id = planeRes->planes[i]; - auto ob = new Plane(*this, id, i); - m_obmap[id] = ob; - m_planes.push_back(ob); + drmModeFreePlaneResources(planeRes); + } } - drmModeFreePlaneResources(planeRes); - // collect all possible props for (auto ob : get_objects()) { auto props = drmModeObjectGetProperties(m_fd, ob->id(), ob->object_type()); |