summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-04-16 19:05:18 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2017-04-16 19:12:43 +0300
commit944dd4fe95db2e29489818a570f010df2bccb06a (patch)
treeca9226388814f1b03e178fcf176b8b44c459073d
parent94a58cd836950743bb1a16c7f48852d0cca57038 (diff)
Return primary plane already associated with the CRTC if it exists
The Crtc::get_primary_plane() method returns the first primary plane that supports the CRTC. While being correct, this could lead to multiple primary planes being associated with the CRTC, which can confuse applications. To avoid that, return insead the primary plane already associated with the CRTC if one exists, otherwise keep the current behaviour. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--kms++/src/crtc.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/kms++/src/crtc.cpp b/kms++/src/crtc.cpp
index 2d41bfa..1a46195 100644
--- a/kms++/src/crtc.cpp
+++ b/kms++/src/crtc.cpp
@@ -95,13 +95,21 @@ int Crtc::disable_plane(Plane* plane)
Plane* Crtc::get_primary_plane()
{
+ Plane *primary = NULL;
+
for (Plane* p : get_possible_planes()) {
if (p->plane_type() != PlaneType::Primary)
continue;
- return p;
+ if (p->crtc_id() == id())
+ return p;
+
+ primary = p;
}
+ if (primary)
+ return primary;
+
throw invalid_argument(string("No primary plane for crtc ") + to_string(id()));
}