summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2016-10-20 17:49:43 -0400
committerRobert Foss <robert.foss@collabora.com>2016-10-26 17:41:15 -0400
commit997207b8aa934bd412601dc76c5b962f72580ead (patch)
tree4b870486684f5e61f99289b75949a0800b1791f1
parente5350a1b8f350a187db8eacb1ff700cbdd864fd7 (diff)
downloaddrm_hwcomposer-997207b8aa934bd412601dc76c5b962f72580ead.tar.gz
drm_hwcomposer-997207b8aa934bd412601dc76c5b962f72580ead.tar.xz
drm_hwcomposer: Added out-fence support
Signed-off-by: Robert Foss <robert.foss@collabora.com>
-rw-r--r--drmdisplaycomposition.h9
-rw-r--r--drmdisplaycompositor.cpp16
-rw-r--r--drmhwctwo.cpp9
3 files changed, 27 insertions, 7 deletions
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index b165adc..0586d58 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -189,6 +189,14 @@ class DrmDisplayComposition {
return planner_;
}
+ int take_out_fence() {
+ return out_fence_.Release();
+ }
+
+ void set_out_fence(int out_fence) {
+ out_fence_.Set(dup(out_fence));
+ }
+
void Dump(std::ostringstream *out) const;
private:
@@ -215,6 +223,7 @@ class DrmDisplayComposition {
int timeline_current_ = 0;
int timeline_squash_done_ = 0;
int timeline_pre_comp_done_ = 0;
+ UniqueFd out_fence_ = -1;
bool geometry_changed_;
std::vector<DrmHwcLayer> layers_;
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index fd9ab45..60d990c 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -492,6 +492,7 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
display_comp->composition_planes();
std::vector<DrmCompositionRegion> &pre_comp_regions =
display_comp->pre_comp_regions();
+ uint64_t out_fences[drm_->GetCrtcCount()];
DrmConnector *connector = drm_->GetConnectorForDisplay(display_);
if (!connector) {
@@ -510,6 +511,16 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
return -ENOMEM;
}
+ if (crtc->out_fence_ptr_property().id() != 0) {
+ ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->out_fence_ptr_property().id(),
+ (uint64_t) &out_fences[0]);
+ if (ret < 0) {
+ ALOGE("Failed to add OUT_FENCE_PTR property to pset: %d", ret);
+ drmModeAtomicFree(pset);
+ return ret;
+ }
+ }
+
if (mode_.needs_modeset) {
ret = drmModeAtomicAddProperty(pset, crtc->id(), crtc->mode_property().id(),
mode_.blob_id) < 0 ||
@@ -702,6 +713,11 @@ out:
mode_.needs_modeset = false;
}
+ if (crtc->out_fence_ptr_property().id()) {
+ display_comp->set_out_fence((int) out_fences[crtc->pipe()]);
+ close((int) out_fences[crtc->pipe()]);
+ }
+
return ret;
}
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index 6f31c1a..2da5392 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -556,19 +556,14 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) {
i = overlay_planes.erase(i);
}
+ AddFenceToRetireFence(composition->take_out_fence());
+
ret = compositor_.ApplyComposition(std::move(composition));
if (ret) {
ALOGE("Failed to apply the frame composition ret=%d", ret);
return HWC2::Error::BadParameter;
}
- // Now that the release fences have been generated by the compositor, make
- // sure they're managed properly
- for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) {
- l.second->manage_release_fence();
- AddFenceToRetireFence(l.second->release_fence());
- }
-
// The retire fence returned here is for the last frame, so return it and
// promote the next retire fence
*retire_fence = retire_fence_.Release();