ResourceManager: reserve_generic_plane() for either primary or overlay
authorJyri Sarha <jsarha@ti.com>
Sat, 11 Mar 2017 11:43:56 +0000 (13:43 +0200)
committerJyri Sarha <jsarha@ti.com>
Mon, 20 Mar 2017 16:20:40 +0000 (18:20 +0200)
kms++util/inc/kms++util/resourcemanager.h
kms++util/src/resourcemanager.cpp

index dac6c9eb6c464a1a4c56ace98ebb693afd482c06..b4a210df01348e41f803cbb8000dd66ad84c30c2 100644 (file)
@@ -16,6 +16,7 @@ public:
        Connector* reserve_connector(Connector* conn);
        Crtc* reserve_crtc(Connector* conn);
        Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined);
+       Plane* reserve_generic_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
        Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
        Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined);
 
index 5c83ad77758ca7a1e0086484d219c88bdb9d9925..23a1480de2903ac2a07dee4196e65d069079fdf4 100644 (file)
@@ -129,7 +129,26 @@ Crtc* ResourceManager::reserve_crtc(Connector* conn)
 Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format)
 {
        for (Plane* plane : crtc->get_possible_planes()) {
-               if (plane->plane_type() != type)
+               if (plane->plane_type() == type)
+                       continue;
+
+               if (format != PixelFormat::Undefined && !plane->supports_format(format))
+                       continue;
+
+               if (contains(m_reserved_planes, plane))
+                       continue;
+
+               m_reserved_planes.push_back(plane);
+               return plane;
+       }
+
+       return nullptr;
+}
+
+Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format)
+{
+       for (Plane* plane : crtc->get_possible_planes()) {
+               if (plane->plane_type() == PlaneType::Cursor)
                        continue;
 
                if (format != PixelFormat::Undefined && !plane->supports_format(format))