Add Crtc::get_primary_plane
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 23 May 2016 06:39:01 +0000 (09:39 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 23 May 2016 06:43:27 +0000 (09:43 +0300)
libkms++/crtc.cpp
libkms++/crtc.h
tests/db.cpp

index c6d79e9c7079dfed1a4a05e1ba5d908fc86c4ad2..deadd62b44550ba82d8857b4f2106e58f3dacfe9 100644 (file)
@@ -80,6 +80,21 @@ int Crtc::disable_plane(Plane* plane)
        return drmModeSetPlane(card().fd(), plane->id(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 }
 
+Plane* Crtc::get_primary_plane()
+{
+       for (Plane* p : get_possible_planes()) {
+               if (p->plane_type() != PlaneType::Primary)
+                       continue;
+
+               if (p->crtc_id() != id())
+                       continue;
+
+               return p;
+       }
+
+       throw invalid_argument("No primary plane for crtc " + id());
+}
+
 int Crtc::page_flip(Framebuffer& fb, void *data)
 {
        return drmModePageFlip(card().fd(), id(), fb.id(), DRM_MODE_PAGE_FLIP_EVENT, data);
index 48baf1bb6a8933b1a15049954208911313c0802d..abe6fed0cb47154d78839f9be68add41d627a881 100644 (file)
@@ -24,6 +24,8 @@ public:
 
        int disable_plane(Plane* plane);
 
+       Plane* get_primary_plane();
+
        int page_flip(Framebuffer& fb, void *data);
        int page_flip(Framebuffer& fb, PageFlipHandlerBase* data) { return page_flip(fb, (void*)data); }
 
index 6b0942e3fd36300af4e57d73b1bb76d366ad2bfc..3e8420bbb1ac4b02d46b0f895f927a9629b24e13 100644 (file)
@@ -93,19 +93,8 @@ public:
                int r = m_crtc->set_mode(m_connector, *fb, m_mode);
                ASSERT(r == 0);
 
-               if (m_crtc->card().has_atomic()) {
-                       Plane* root_plane = 0;
-                       for (Plane* p : m_crtc->get_possible_planes()) {
-                               if (p->crtc_id() == m_crtc->id()) {
-                                       root_plane = p;
-                                       break;
-                               }
-                       }
-
-                       FAIL_IF(!root_plane, "No primary plane for crtc %d", m_crtc->id());
-
-                       m_root_plane = root_plane;
-               }
+               if (m_crtc->card().has_atomic())
+                       m_root_plane = m_crtc->get_primary_plane();
 
                if (m_plane) {
                        auto planefb = m_plane_flipper->get_next();