summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalyan Kondapally <kalyan.kondapally@intel.com>2017-03-02 20:59:10 -0800
committerRobert Foss <robert.foss@collabora.com>2017-03-22 14:38:43 -0400
commit4424da9f3247a1709ba3c29dd7ad4d80fa167820 (patch)
treef1676b4e077b9925c6f0ed72006b74a37d30d644
parent26dcb6d8b8657911a4c8bb16d7bfb19b733b2255 (diff)
downloaddrm_hwcomposer-4424da9f3247a1709ba3c29dd7ad4d80fa167820.tar.gz
drm_hwcomposer-4424da9f3247a1709ba3c29dd7ad4d80fa167820.tar.xz
drm_hwcomposer: Track Cursor Layers/planes separately
On IA platforms, we have a plane dedicated for Cursor. We should be using this to show cursor instead of an Overlay on IA platforms. This patch adds initial support to track Cursor layer and plane separately. BUG=None TEST=No Graphics regressions observed on Skylake platform. Change-Id: I800d0d5dda04be67cbab97272bd9723e6715a50d Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
-rw-r--r--drmdisplaycomposition.cpp5
-rw-r--r--drmdisplaycomposition.h3
-rw-r--r--drmhwctwo.cpp9
-rw-r--r--drmhwctwo.h1
-rw-r--r--platform.cpp34
-rw-r--r--platform.h6
6 files changed, 52 insertions, 6 deletions
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index bc1d668..ec591af 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -290,7 +290,8 @@ int DrmDisplayComposition::CreateAndAssignReleaseFences() {
int DrmDisplayComposition::Plan(SquashState *squash,
std::vector<DrmPlane *> *primary_planes,
- std::vector<DrmPlane *> *overlay_planes) {
+ std::vector<DrmPlane *> *overlay_planes,
+ std::vector<DrmPlane *> *cursor_planes) {
if (type_ != DRM_COMPOSITION_TYPE_FRAME)
return 0;
@@ -368,7 +369,7 @@ int DrmDisplayComposition::Plan(SquashState *squash,
std::vector<DrmCompositionPlane> plan;
std::tie(ret, composition_planes_) =
planner_->ProvisionPlanes(to_composite, use_squash_framebuffer, crtc_,
- primary_planes, overlay_planes);
+ primary_planes, overlay_planes, cursor_planes);
if (ret) {
ALOGE("Planner failed provisioning planes ret=%d", ret);
return ret;
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 0586d58..4e016da 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -126,7 +126,8 @@ class DrmDisplayComposition {
int SetDisplayMode(const DrmMode &display_mode);
int Plan(SquashState *squash, std::vector<DrmPlane *> *primary_planes,
- std::vector<DrmPlane *> *overlay_planes);
+ std::vector<DrmPlane *> *overlay_planes,
+ std::vector<DrmPlane *> *cursor_planes);
int FinalizeComposition();
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index c836930..45511c6 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -195,6 +195,8 @@ HWC2::Error DrmHwcTwo::HwcDisplay::Init(std::vector<DrmPlane *> *planes) {
primary_planes_.push_back(plane);
else if (use_overlay_planes && (plane)->type() == DRM_PLANE_TYPE_OVERLAY)
overlay_planes_.push_back(plane);
+ else if (plane->type() == DRM_PLANE_TYPE_CURSOR)
+ cursor_planes_.push_back(plane);
}
crtc_ = drm_->GetCrtcForDisplay(display);
@@ -544,8 +546,9 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) {
std::vector<DrmPlane *> primary_planes(primary_planes_);
std::vector<DrmPlane *> overlay_planes(overlay_planes_);
+ std::vector<DrmPlane *> cursor_planes(cursor_planes_);
ret = composition->Plan(compositor_.squash_state(), &primary_planes,
- &overlay_planes);
+ &overlay_planes, &cursor_planes);
if (ret) {
ALOGE("Failed to plan the composition ret=%d", ret);
return HWC2::Error::BadConfig;
@@ -560,6 +563,10 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) {
composition->AddPlaneDisable(*i);
i = overlay_planes.erase(i);
}
+ for (auto i = cursor_planes.begin(); i != cursor_planes.end();) {
+ composition->AddPlaneDisable(*i);
+ i = cursor_planes.erase(i);
+ }
AddFenceToRetireFence(composition->take_out_fence());
diff --git a/drmhwctwo.h b/drmhwctwo.h
index 0490e2a..2d50b7e 100644
--- a/drmhwctwo.h
+++ b/drmhwctwo.h
@@ -196,6 +196,7 @@ class DrmHwcTwo : public hwc2_device_t {
std::vector<DrmPlane *> primary_planes_;
std::vector<DrmPlane *> overlay_planes_;
+ std::vector<DrmPlane *> cursor_planes_;
VSyncWorker vsync_worker_;
DrmConnector *connector_ = NULL;
diff --git a/platform.cpp b/platform.cpp
index 105d8f7..1c36655 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -36,10 +36,26 @@ std::vector<DrmPlane *> Planner::GetUsablePlanes(
return usable_planes;
}
+DrmPlane *Planner::PopUsableCursorPlane(
+ DrmCrtc *crtc, std::vector<DrmPlane *> *cursor_planes) {
+ DrmPlane *cursor_plane = NULL;
+ for (auto i = cursor_planes->begin(); i != cursor_planes->end(); ++i) {
+ if ((*i)->type() == DRM_PLANE_TYPE_CURSOR &&
+ (*i)->GetCrtcSupported(*crtc)) {
+ cursor_plane = *i;
+ cursor_planes->erase(i);
+ break;
+ }
+ }
+
+ return cursor_plane;
+}
+
std::tuple<int, std::vector<DrmCompositionPlane>> Planner::ProvisionPlanes(
std::map<size_t, DrmHwcLayer *> &layers, bool use_squash_fb, DrmCrtc *crtc,
std::vector<DrmPlane *> *primary_planes,
- std::vector<DrmPlane *> *overlay_planes) {
+ std::vector<DrmPlane *> *overlay_planes,
+ std::vector<DrmPlane *> *cursor_planes) {
std::vector<DrmCompositionPlane> composition;
std::vector<DrmPlane *> planes =
GetUsablePlanes(crtc, primary_planes, overlay_planes);
@@ -72,6 +88,22 @@ std::tuple<int, std::vector<DrmCompositionPlane>> Planner::ProvisionPlanes(
}
}
+ // If we have dedicated cursor plane, try using it to composite cursor
+ // layer.
+ if (cursor_planes) {
+ for (auto j = layers.begin(); j != layers.end(); ++j) {
+ if (j->second->gralloc_buffer_usage & GRALLOC_USAGE_CURSOR) {
+ DrmPlane *cursor_plane = PopUsableCursorPlane(crtc, cursor_planes);
+ if (cursor_plane) {
+ composition.emplace_back(DrmCompositionPlane::Type::kLayer,
+ cursor_plane, crtc, j->first);
+ layers.erase(j);
+ }
+ break;
+ }
+ }
+ }
+
// Go through the provisioning stages and provision planes
for (auto &i : stages_) {
int ret = i->ProvisionPlanes(&composition, layers, crtc, &planes);
diff --git a/platform.h b/platform.h
index 2122f67..95ba5f3 100644
--- a/platform.h
+++ b/platform.h
@@ -138,7 +138,8 @@ class Planner {
std::tuple<int, std::vector<DrmCompositionPlane>> ProvisionPlanes(
std::map<size_t, DrmHwcLayer *> &layers, bool use_squash_fb,
DrmCrtc *crtc, std::vector<DrmPlane *> *primary_planes,
- std::vector<DrmPlane *> *overlay_planes);
+ std::vector<DrmPlane *> *overlay_planes,
+ std::vector<DrmPlane *> *cursor_planes);
template <typename T, typename... A>
void AddStage(A &&... args) {
@@ -151,6 +152,9 @@ class Planner {
DrmCrtc *crtc, std::vector<DrmPlane *> *primary_planes,
std::vector<DrmPlane *> *overlay_planes);
+ DrmPlane *PopUsableCursorPlane(DrmCrtc *crtc,
+ std::vector<DrmPlane *> *cursor_planes);
+
std::vector<std::unique_ptr<PlanStage>> stages_;
};