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/platform.cpp b/platform.cpp
index af18124..9e0eb45 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -36,6 +36,50 @@
return usable_planes;
}
+int Planner::PlanStage::ValidatePlane(DrmPlane *plane, DrmHwcLayer *layer) {
+ int ret = 0;
+ uint64_t blend;
+
+ if ((plane->rotation_property().id() == 0) &&
+ layer->transform != DrmHwcTransform::kIdentity) {
+ ALOGE("Rotation is not supported on plane %d", plane->id());
+ return -EINVAL;
+ }
+
+ if (plane->alpha_property().id() == 0 && layer->alpha != 0xffff) {
+ ALOGE("Alpha is not supported on plane %d", plane->id());
+ return -EINVAL;
+ }
+
+ if (plane->blend_property().id() == 0) {
+ if ((layer->blending != DrmHwcBlending::kNone) &&
+ (layer->blending != DrmHwcBlending::kPreMult)) {
+ ALOGE("Blending is not supported on plane %d", plane->id());
+ return -EINVAL;
+ }
+ } else {
+ 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;
+ }
+ if (ret)
+ ALOGE("Expected a valid blend mode on plane %d", plane->id());
+ }
+
+ return ret;
+}
+
std::tuple<int, std::vector<DrmCompositionPlane>> Planner::ProvisionPlanes(
std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
std::vector<DrmPlane *> *primary_planes,
@@ -73,7 +117,7 @@
}
ret = Emplace(composition, planes, DrmCompositionPlane::Type::kLayer, crtc,
- i->first);
+ std::make_pair(i->first, i->second));
if (ret)
ALOGE("Failed to dedicate protected layer! Dropping it.");
@@ -91,7 +135,7 @@
// Fill up the remaining planes
for (auto i = layers.begin(); i != layers.end(); i = layers.erase(i)) {
int ret = Emplace(composition, planes, DrmCompositionPlane::Type::kLayer,
- crtc, i->first);
+ crtc, std::make_pair(i->first, i->second));
// We don't have any planes left
if (ret == -ENOENT)
break;