plane: add get_possible_crtcs()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 13 Mar 2017 09:08:40 +0000 (11:08 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 13 Mar 2017 09:08:40 +0000 (11:08 +0200)
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
kms++/inc/kms++/plane.h
kms++/src/plane.cpp

index 26f3951915f06ddda63a4b632d9627757da83b0e..27e819b8380271f82f7996d9e06ba733e3b844fe 100644 (file)
@@ -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;
index e19910bc2258422bc90700be2583da25c7e785c4..f68c8d062bfff17bc24862fff04710bcaa428595 100644 (file)
@@ -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;