From: Greg Hackmann Date: Tue, 2 Oct 2012 18:39:13 +0000 (-0700) Subject: hwc: set retire fence fds X-Git-Tag: cm-10.2-M1^2~42 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=02893a485dfa8b9c98904794325ed0b467c40c4e;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git hwc: set retire fence fds Change-Id: Iece6483e6402a9a425086b8ee8e67e17909b7d8a --- diff --git a/libhwc/hwc.cpp b/libhwc/hwc.cpp index c23e6f0..e210fc2 100644 --- a/libhwc/hwc.cpp +++ b/libhwc/hwc.cpp @@ -198,6 +198,22 @@ inline int HEIGHT(const hwc_rect &rect) { return rect.bottom - rect.top; } template inline T max(T a, T b) { return (a > b) ? a : b; } template inline T min(T a, T b) { return (a < b) ? a : b; } +static int dup_or_warn(int fence) +{ + int dup_fd = dup(fence); + if (dup_fd < 0) + ALOGW("fence dup failed: %s", strerror(errno)); + return dup_fd; +} + +static int merge_or_warn(const char *name, int f1, int f2) +{ + int merge_fd = sync_merge(name, f1, f2); + if (merge_fd < 0) + ALOGW("fence merge failed: %s", strerror(errno)); + return merge_fd; +} + template void align_crop_and_center(T &w, T &h, hwc_rect_t *crop, size_t alignment) { @@ -1487,9 +1503,7 @@ static int exynos5_set_fimd(exynos5_hwc_composer_device_1_t *pdev, if (pdev->bufs.overlay_map[i] != -1) { hwc_layer_1_t &layer = contents->hwLayers[pdev->bufs.overlay_map[i]]; - int dup_fd = dup(fence); - if (dup_fd < 0) - ALOGW("release fence dup failed: %s", strerror(errno)); + int dup_fd = dup_or_warn(fence); if (pdev->bufs.gsc_map[i].mode == exynos5_gsc_map_t::GSC_M2M) { int gsc_idx = pdev->bufs.gsc_map[i].idx; exynos5_gsc_data_t &gsc = pdev->gsc[gsc_idx]; @@ -1500,7 +1514,7 @@ static int exynos5_set_fimd(exynos5_hwc_composer_device_1_t *pdev, } } } - close(fence); + contents->retireFenceFd = fence; return err; } @@ -1557,6 +1571,14 @@ static int exynos5_set_hdmi(exynos5_hwc_composer_device_1_t *pdev, gsc.dst_buf_fence[gsc.current_buf] = releaseFenceFd; gsc.current_buf = (gsc.current_buf + 1) % NUM_GSC_DST_BUFS; + if (contents->retireFenceFd < 0) + contents->retireFenceFd = dup_or_warn(releaseFenceFd); + else { + int merged = merge_or_warn("hdmi", + contents->retireFenceFd, layer.releaseFenceFd); + close(contents->retireFenceFd); + contents->retireFenceFd = merged; + } } if (layer.compositionType == HWC_FRAMEBUFFER_TARGET) { @@ -1570,6 +1592,14 @@ static int exynos5_set_hdmi(exynos5_hwc_composer_device_1_t *pdev, hdmi_output(pdev, pdev->hdmi_layers[1], layer, h, layer.acquireFenceFd, &layer.releaseFenceFd); fb_layer = &layer; + if (contents->retireFenceFd < 0) + contents->retireFenceFd = dup_or_warn(layer.releaseFenceFd); + else { + int merged = merge_or_warn("hdmi", + contents->retireFenceFd, layer.releaseFenceFd); + close(contents->retireFenceFd); + contents->retireFenceFd = merged; + } } }