]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/commitdiff
Return primary plane already associated with the CRTC if it exists
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 16 Apr 2017 16:07:40 +0000 (19:07 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 21 Apr 2017 12:36:59 +0000 (15:36 +0300)
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>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
kms++/src/crtc.cpp

index 2d41bfac0a67f37ec998abe49e1dd920beca9e9a..c391f69de020649bef607483c54b390132503701 100644 (file)
@@ -95,13 +95,21 @@ int Crtc::disable_plane(Plane* plane)
 
 Plane* Crtc::get_primary_plane()
 {
 
 Plane* Crtc::get_primary_plane()
 {
+       Plane *primary = nullptr;
+
        for (Plane* p : get_possible_planes()) {
                if (p->plane_type() != PlaneType::Primary)
                        continue;
 
        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()));
 }
 
        throw invalid_argument(string("No primary plane for crtc ") + to_string(id()));
 }