drm_hwcomposer: Add support for pixel blend mode property

The upstream version of pixel blend mode property will be added
to the DRM core. So added support for pixel blend mode property
to the DrmPlane.

Created ValidatePlane() function in Planner to do the blend check,
and also moved rotation and plane alpha property check there.

Fixed the Emplace() call in platformhisi.cpp as was done with the
other planner implementations.

Change-Id: I7e6714699cf7c222a83de472060d4625e1e6945a
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Lowry Li <lowry.li@arm.com>
Tested-by: John Stultz <john.stultz@linaro.org>
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index f479f10..cd6d4b2 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -316,6 +316,7 @@
     hwc_frect_t source_crop;
     uint64_t rotation = 0;
     uint64_t alpha = 0xFFFF;
+    uint64_t blend;
 
     if (comp_plane.type() != DrmCompositionPlane::Type::kDisable) {
       if (source_layers.size() > 1) {
@@ -338,8 +339,25 @@
       fence_fd = layer.acquire_fence.get();
       display_frame = layer.display_frame;
       source_crop = layer.source_crop;
-      if (layer.blending == DrmHwcBlending::kPreMult)
-        alpha = layer.alpha;
+      alpha = layer.alpha;
+
+      if (plane->blend_property().id()) {
+        switch (layer.blending) {
+          case DrmHwcBlending::kPreMult:
+            std::tie(blend, ret) = plane->blend_property().GetEnumValueWithName(
+                "Pre-multiplied");
+            break;
+          case DrmHwcBlending::kCoverage:
+            std::tie(blend, ret) = plane->blend_property().GetEnumValueWithName(
+                "Coverage");
+            break;
+          case DrmHwcBlending::kNone:
+          default:
+            std::tie(blend, ret) = plane->blend_property().GetEnumValueWithName(
+                "None");
+            break;
+        }
+      }
 
       rotation = 0;
       if (layer.transform & DrmHwcTransform::kFlipH)
@@ -382,20 +400,6 @@
       continue;
     }
 
-    // TODO: Once we have atomic test, this should fall back to GL
-    if (rotation != DRM_MODE_ROTATE_0 && plane->rotation_property().id() == 0) {
-      ALOGV("Rotation is not supported on plane %d", plane->id());
-      ret = -EINVAL;
-      break;
-    }
-
-    // TODO: Once we have atomic test, this should fall back to GL
-    if (alpha != 0xFFFF && plane->alpha_property().id() == 0) {
-      ALOGV("Alpha is not supported on plane %d", plane->id());
-      ret = -EINVAL;
-      break;
-    }
-
     ret = drmModeAtomicAddProperty(pset, plane->id(),
                                    plane->crtc_property().id(), crtc->id()) < 0;
     ret |= drmModeAtomicAddProperty(pset, plane->id(),
@@ -453,6 +457,16 @@
         break;
       }
     }
+
+    if (plane->blend_property().id()) {
+      ret = drmModeAtomicAddProperty(pset, plane->id(),
+                                     plane->blend_property().id(), blend) < 0;
+      if (ret) {
+        ALOGE("Failed to add pixel blend mode property %d to plane %d",
+              plane->blend_property().id(), plane->id());
+        break;
+      }
+    }
   }
 
   if (!ret) {