From cfc1318f7ac480622f5bd70f1f9fbf97fe7d906d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 16 Apr 2017 19:07:40 +0300 Subject: [PATCH] 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 Signed-off-by: Tomi Valkeinen --- kms++/src/crtc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kms++/src/crtc.cpp b/kms++/src/crtc.cpp index 2d41bfa..c391f69 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 = nullptr; + 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())); } -- 2.39.2