diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-13 11:08:40 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-13 11:08:40 +0200 |
commit | 097c297e4d4e4113f942d03112d40302a00b78f8 (patch) | |
tree | f34134a7e59088a6d21f527b2b299d11f1544440 /kms++ | |
parent | 3115684d76a10f75d523c4532822e524994757bc (diff) |
plane: add get_possible_crtcs()
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
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; |