diff options
Diffstat (limited to 'kms++')
-rw-r--r-- | kms++/inc/kms++/plane.h | 1 | ||||
-rw-r--r-- | kms++/src/plane.cpp | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/kms++/inc/kms++/plane.h b/kms++/inc/kms++/plane.h index 26f3951..27e819b 100644 --- a/kms++/inc/kms++/plane.h +++ b/kms++/inc/kms++/plane.h @@ -23,6 +23,7 @@ public: PlaneType plane_type() const; + std::vector<Crtc*> get_possible_crtcs() const; std::vector<PixelFormat> get_formats() const; uint32_t crtc_id() const; uint32_t fb_id() const; diff --git a/kms++/src/plane.cpp b/kms++/src/plane.cpp index e19910b..f68c8d0 100644 --- a/kms++/src/plane.cpp +++ b/kms++/src/plane.cpp @@ -5,6 +5,7 @@ #include <cassert> #include <xf86drm.h> #include <xf86drmMode.h> +#include <algorithm> #include <kms++/kms++.h> @@ -66,6 +67,30 @@ PlaneType Plane::plane_type() const } } +vector<Crtc*> Plane::get_possible_crtcs() const +{ + unsigned idx = 0; + vector<Crtc*> v; + auto crtcs = card().get_crtcs(); + + for (uint32_t crtc_mask = m_priv->drm_plane->possible_crtcs; + crtc_mask; + idx++, crtc_mask >>= 1) { + + if ((crtc_mask & 1) == 0) + continue; + + auto iter = find_if(crtcs.begin(), crtcs.end(), [idx](Crtc* crtc) { return crtc->idx() == idx; }); + + if (iter == crtcs.end()) + throw runtime_error("get_possible_crtcs: crtc missing"); + + v.push_back(*iter); + } + + return v; +} + vector<PixelFormat> Plane::get_formats() const { auto p = m_priv->drm_plane; |