@@ -179,6 +179,14 @@ class DrmDisplayComposition {
return planner_;
}
+ int take_out_fence() {
+ return out_fence_.Release();
+ }
+
+ void set_out_fence(int out_fence) {
+ out_fence_.Set(out_fence);
+ }
+
void Dump(std::ostringstream *out) const;
private:
@@ -205,6 +213,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_;
@@ -602,6 +602,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_->crtcs().size()];
DrmConnector *connector = drm_->GetConnectorForDisplay(display_);
if (!connector) {
@@ -620,6 +621,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[crtc->pipe()]);
+ 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 ||
@@ -818,6 +829,10 @@ out:
mode_.needs_modeset = false;
}
+ if (crtc->out_fence_ptr_property().id()) {
+ display_comp->set_out_fence((int) out_fences[crtc->pipe()]);
+ }
+
return ret;
}
@@ -557,19 +557,14 @@ HWC2::Error DrmHwcTwo::HwcDisplay::PresentDisplay(int32_t *retire_fence) {
i = overlay_planes.erase(i);
}
+ AddFenceToRetireFence(composition->take_out_fence());
+
ret = compositor_.QueueComposition(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();