summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-05-23 09:39:01 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-05-23 09:43:27 +0300
commit6bc7077ff215bb2a3fc017560dd5a814aeaf4f6d (patch)
treed1622c5f086b16f8b57292153ac5e8f023b353a9
parent67019d74bb312dcb8580ae2684664b62dbc005b9 (diff)
Add Crtc::get_primary_plane
-rw-r--r--libkms++/crtc.cpp15
-rw-r--r--libkms++/crtc.h2
-rw-r--r--tests/db.cpp15
3 files changed, 19 insertions, 13 deletions
diff --git a/libkms++/crtc.cpp b/libkms++/crtc.cpp
index c6d79e9..deadd62 100644
--- a/libkms++/crtc.cpp
+++ b/libkms++/crtc.cpp
@@ -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);
diff --git a/libkms++/crtc.h b/libkms++/crtc.h
index 48baf1b..abe6fed 100644
--- a/libkms++/crtc.h
+++ b/libkms++/crtc.h
@@ -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); }
diff --git a/tests/db.cpp b/tests/db.cpp
index 6b0942e..3e8420b 100644
--- a/tests/db.cpp
+++ b/tests/db.cpp
@@ -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();