OSDN Git Service

drm_hwcomposer: Fixup Sean's HiSi dummy planner
authorJohn Stultz <john.stultz@linaro.org>
Tue, 28 Aug 2018 05:24:40 +0000 (22:24 -0700)
committerJohn Stultz <john.stultz@linaro.org>
Tue, 28 Aug 2018 21:28:39 +0000 (14:28 -0700)
The dummy HiSi Planner is careful to not try to emplace layers
that aren't HW_FB. However, in some cases we might have a single
layer to draw. In that case the dummy importer will pretend it
imported the buffer, and the planner will skip over it and not
emplace it. Since there were no errors and the layers_ count is
the same as the available planes, we won't force client
composition, and will try to do device composition for the
buffer we didn't really import.

This results in the drm layer going a bit wonky.

Thus, this patch tries to fix this by erroring out if we try to
plan only a single layer, but don't emplace anything. This
results in the CreateComposition() function failing, which will
force client rendering, making it work (with only minimal logcat
noise - only in the single layer case).

Change-Id: I563dbba3c2adce5617fae61cb0440368053e5bff
Signed-off-by: John Stultz <john.stultz@linaro.org>
platformhisi.cpp

index e2012ec..99d222b 100644 (file)
@@ -143,6 +143,8 @@ class PlanStageHiSi : public Planner::PlanStage {
   int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
                       std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
                       std::vector<DrmPlane *> *planes) {
+    int layers_added = 0;
+    int initial_layers = layers.size();
     // Fill up as many planes as we can with buffers that do not have HW_FB
     // usage
     for (auto i = layers.begin(); i != layers.end(); i = layers.erase(i)) {
@@ -151,12 +153,22 @@ class PlanStageHiSi : public Planner::PlanStage {
 
       int ret = Emplace(composition, planes, DrmCompositionPlane::Type::kLayer,
                         crtc, i->first);
+      layers_added++;
       // We don't have any planes left
       if (ret == -ENOENT)
         break;
       else if (ret)
         ALOGE("Failed to emplace layer %zu, dropping it", i->first);
     }
+    /*
+     * If we only have one layer, but we didn't emplace anything, we
+     * can run into trouble, as we might try to device composite a
+     * buffer we fake-imported, which can cause things to jamb up.
+     * So return an error in this case to ensure we force client
+     * compositing.
+     */
+    if (!layers_added && (initial_layers <= 1))
+      return -EINVAL;
 
     return 0;
   }