summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2016-10-19 10:46:22 -0400
committerRobert Foss <robert.foss@collabora.com>2017-03-22 14:38:43 -0400
commitd72af41c6545b8e4503bdb2a51a6188393b68a5d (patch)
tree359b3514a19afae6aa87db36b1df0b54c2742d68
parent7970d2fc15396ff019f5d635a8ed7dd01b5c32dd (diff)
downloaddrm_hwcomposer-d72af41c6545b8e4503bdb2a51a6188393b68a5d.tar.gz
drm_hwcomposer-d72af41c6545b8e4503bdb2a51a6188393b68a5d.tar.xz
drm_hwcomposer: Submit in-fence to DRM
Add support for in-fences through the IN_FENCE_FD property. In-fences signal when their associated buffer may be read by DRM/KMS. BUG=None TEST=Tested on Qemu+drm_hwcomposer Change-Id: Iab76cf38fc7ce2472eefcdf49749009337f2e27a Signed-off-by: Robert Foss <robert.foss@collabora.com>
-rw-r--r--drmdisplaycompositor.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index bd670cf..71c0451 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -529,6 +529,7 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
std::vector<size_t> &source_layers = comp_plane.source_layers();
int fb_id = -1;
+ int fence_fd = -1;
DrmHwcRect<int> display_frame;
DrmHwcRect<float> source_crop;
uint64_t rotation = 0;
@@ -547,30 +548,12 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
break;
}
DrmHwcLayer &layer = layers[source_layers.front()];
- if (!test_only && layer.acquire_fence.get() >= 0) {
- int acquire_fence = layer.acquire_fence.get();
- int total_fence_timeout = 0;
- for (int i = 0; i < kAcquireWaitTries; ++i) {
- int fence_timeout = kAcquireWaitTimeoutMs * (1 << i);
- total_fence_timeout += fence_timeout;
- ret = sync_wait(acquire_fence, fence_timeout);
- if (ret)
- ALOGW("Acquire fence %d wait %d failed (%d). Total time %d",
- acquire_fence, i, ret, total_fence_timeout);
- else
- break;
- }
- if (ret) {
- ALOGE("Failed to wait for acquire %d/%d", acquire_fence, ret);
- break;
- }
- layer.acquire_fence.Close();
- }
if (!layer.buffer) {
ALOGE("Expected a valid framebuffer for pset");
break;
}
fb_id = layer.buffer->fb_id;
+ fence_fd = layer.acquire_fence.get();
display_frame = layer.display_frame;
source_crop = layer.source_crop;
if (layer.blending == DrmHwcBlending::kPreMult)
@@ -587,7 +570,21 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
rotation |= 1 << DRM_ROTATE_180;
else if (layer.transform & DrmHwcTransform::kRotate270)
rotation |= 1 << DRM_ROTATE_270;
+
+ if (fence_fd != -1) {
+ int prop_id = plane->in_fence_fd_property().id();
+ if (prop_id == 0) {
+ ALOGE("Failed to get IN_FENCE_FD property id");
+ break;
+ }
+ ret = drmModeAtomicAddProperty(pset, plane->id(), prop_id, fence_fd);
+ if (ret < 0) {
+ ALOGE("Failed to add IN_FENCE_FD property to pset: %d", ret);
+ break;
+ }
+ }
}
+
// Disable the plane if there's no framebuffer
if (fb_id < 0) {
ret = drmModeAtomicAddProperty(pset, plane->id(),