PlaneType to bitmask
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 7 Feb 2017 11:58:52 +0000 (13:58 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 10 Feb 2017 08:42:53 +0000 (10:42 +0200)
kms++/inc/kms++/plane.h
kms++/src/plane.cpp

index d50e5395c6107ffa5005ae296cce365e7176e5c5..26f3951915f06ddda63a4b632d9627757da83b0e 100644 (file)
@@ -7,9 +7,9 @@ namespace kms
 
 enum class PlaneType
 {
-       Overlay = 0,
-       Primary = 1,
-       Cursor = 2,
+       Overlay = 1 << 0,
+       Primary = 1 << 1,
+       Cursor = 1 << 2,
 };
 
 struct PlanePriv;
index 10aaedaf66101a0659f53bc2f752783b62adfa7a..e19910bc2258422bc90700be2583da25c7e785c4 100644 (file)
@@ -50,10 +50,20 @@ bool Plane::supports_format(PixelFormat fmt) const
 
 PlaneType Plane::plane_type() const
 {
-       if (card().has_has_universal_planes())
-               return (PlaneType)get_prop_value("type");
-       else
+       if (card().has_has_universal_planes()) {
+               switch (get_prop_value("type")) {
+               case DRM_PLANE_TYPE_OVERLAY:
+                       return PlaneType::Overlay;
+               case DRM_PLANE_TYPE_PRIMARY:
+                       return PlaneType::Primary;
+               case DRM_PLANE_TYPE_CURSOR:
+                       return PlaneType::Cursor;
+               default:
+                       throw invalid_argument("Bad plane type");
+               }
+       } else {
                return PlaneType::Overlay;
+       }
 }
 
 vector<PixelFormat> Plane::get_formats() const