From 097c297e4d4e4113f942d03112d40302a00b78f8 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 13 Mar 2017 11:08:40 +0200 Subject: plane: add get_possible_crtcs() Signed-off-by: Tomi Valkeinen --- kms++/inc/kms++/plane.h | 1 + kms++/src/plane.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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 get_possible_crtcs() const; std::vector 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 #include #include +#include #include @@ -66,6 +67,30 @@ PlaneType Plane::plane_type() const } } +vector Plane::get_possible_crtcs() const +{ + unsigned idx = 0; + vector 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 Plane::get_formats() const { auto p = m_priv->drm_plane; -- cgit v1.2.3