drm_hwcomposer: Fix HiSi import fail log spam
hikey can only display layers which do not have gralloc usage HW_FB
(hint: that leaves just the client target layer). As such, there's no
benefit trying to import them since it'll just fail. So if we encounter
a layer such as this, fake the import (the release will be a noop since
gem_handles will be 0).
Also, as a belt-and-suspenders move, replace the greedy planner with one
that only displays (usage != HW_FB) to be doubly sure that we don't try
to display the no-op layers
Change-Id: I7bf88cfb7bda1dd5f47b741709619494431558a2
Signed-off-by: Sean Paul <seanpaul@chromium.org>
diff --git a/platformhisi.cpp b/platformhisi.cpp
index 5a1ac1b..e2012ec 100644
--- a/platformhisi.cpp
+++ b/platformhisi.cpp
@@ -71,11 +71,18 @@
}
int HisiImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+ memset(bo, 0, sizeof(hwc_drm_bo_t));
+
private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
handle);
if (!hnd)
return -EINVAL;
+ // We can't import these types of buffers, so pretend we did and rely on the
+ // planner to skip them when choosing layers for planes
+ if (!(hnd->usage & GRALLOC_USAGE_HW_FB))
+ return 0;
+
uint32_t gem_handle;
int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle);
if (ret) {
@@ -87,7 +94,6 @@
if (fmt < 0)
return fmt;
- memset(bo, 0, sizeof(hwc_drm_bo_t));
bo->width = hnd->width;
bo->height = hnd->height;
bo->format = fmt;
@@ -132,9 +138,33 @@
return ret;
}
+class PlanStageHiSi : public Planner::PlanStage {
+ public:
+ int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
+ std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
+ std::vector<DrmPlane *> *planes) {
+ // 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)) {
+ if (!(i->second->gralloc_buffer_usage & GRALLOC_USAGE_HW_FB))
+ continue;
+
+ int ret = Emplace(composition, planes, DrmCompositionPlane::Type::kLayer,
+ crtc, i->first);
+ // We don't have any planes left
+ if (ret == -ENOENT)
+ break;
+ else if (ret)
+ ALOGE("Failed to emplace layer %zu, dropping it", i->first);
+ }
+
+ return 0;
+ }
+};
+
std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
std::unique_ptr<Planner> planner(new Planner);
- planner->AddStage<PlanStageGreedy>();
+ planner->AddStage<PlanStageHiSi>();
return planner;
}
} // namespace android