From 60f5e32d4bd25ab8248b6f2f6199854bcf96b55a Mon Sep 17 00:00:00 2001 From: John Stultz Date: Mon, 27 Aug 2018 22:24:40 -0700 Subject: [PATCH] drm_hwcomposer: Fixup Sean's HiSi dummy planner 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 --- platformhisi.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platformhisi.cpp b/platformhisi.cpp index e2012ec..99d222b 100644 --- a/platformhisi.cpp +++ b/platformhisi.cpp @@ -143,6 +143,8 @@ class PlanStageHiSi : public Planner::PlanStage { int ProvisionPlanes(std::vector *composition, std::map &layers, DrmCrtc *crtc, std::vector *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; } -- 2.11.0