[RFC][PATCH 2/2] drm_hwcomposer: Fall back to client compositon if the gl precompostior fails

John Stultz john.stultz at linaro.org
Tue Apr 24 00:06:44 UTC 2018


If the gl precompositor isn't being used, we cannot accept
every layer as a device composited layer.

Thus this patch adds some extra logic in the validate function
to try to map layers to available device planes, falling back
to client side compositing if we run-out of planes.

Credit to Rob Herring, who's work this single plane patch was
originally based on.

Feedback or alternative ideas would be greatly appreciated!

Cc: Marissa Wall <marissaw at google.com>
Cc: Sean Paul <seanpaul at google.com>
Cc: Dmitry Shmidt <dimitrysh at google.com>
Cc: Robert Foss <robert.foss at collabora.com>
Cc: Matt Szczesiak <matt.szczesiak at arm.com>
Cc: Liviu Dudau <Liviu.Dudau at arm.com>
Cc: David Hanna <david.hanna11 at gmail.com>
Cc: Rob Herring <rob.herring at linaro.org>
Cc: Alexandru-Cosmin Gheorghe <Alexandru-Cosmin.Gheorghe at arm.com>
Cc: Alistair Strachan <astrachan at google.com>
Signed-off-by: John Stultz <john.stultz at linaro.org>
Signed-off-by: John Stultz <john.stultz at linaro.org>
---
 drmhwctwo.cpp | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index dfca1a6..437a439 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -686,6 +686,15 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
   supported(__func__);
   *num_types = 0;
   *num_requests = 0;
+  int avail_planes = primary_planes_.size() + overlay_planes_.size();
+
+  /*
+   * If more layers then planes, save one plane
+   * for client composited layers
+   */
+  if (avail_planes < layers_.size())
+	avail_planes--;
+
   for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
     DrmHwcTwo::HwcLayer &layer = l.second;
     switch (layer.sf_type()) {
@@ -695,6 +704,15 @@ HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
         layer.set_validated_type(HWC2::Composition::Client);
         ++*num_types;
         break;
+      case HWC2::Composition::Device:
+        if (!compositor_.uses_GL() && !avail_planes) {
+          layer.set_validated_type(HWC2::Composition::Client);
+          ++*num_types;
+          break;
+        } else {
+	   avail_planes--;
+	}
+	/* fall through */
       default:
         layer.set_validated_type(layer.sf_type());
         break;
-- 
2.7.4



More information about the dri-devel mailing list