From fe072b1147140ff21b48f0ff8b48a7f011249904 Mon Sep 17 00:00:00 2001 From: manxiaoliang Date: Thu, 6 Mar 2025 00:41:59 +0000 Subject: [PATCH] Enable display MULTI_THREADED_PRESENT capability Tracked-On: OAM-130670 Signed-off-by: manxiaoliang --- hwc2_device/HwcDisplay.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp index 6a250e85..69d1df8c 100644 --- a/hwc2_device/HwcDisplay.cpp +++ b/hwc2_device/HwcDisplay.cpp @@ -623,15 +623,16 @@ HWC2::Error HwcDisplay::PresentDisplay(int32_t *out_present_fence) { struct timespec vsync {}; clock_gettime(CLOCK_MONOTONIC, &vsync); int64_t timestamp = (int64_t)vsync.tv_sec * kOneSecondNs + (int64_t)vsync.tv_nsec; - int64_t half_period = (1E9 / staged_mode_->v_refresh()) / 2; - if ((expectedPresentTime_->timestampNanos - timestamp) > half_period) { - int64_t sleep_ms = (expectedPresentTime_->timestampNanos - timestamp - half_period) / (1000 * 1000); + + int64_t period = (1E9 / staged_mode_->v_refresh()); + if ((expectedPresentTime_->timestampNanos - timestamp) > period) { + ATRACE_NAME("Wait for expected present time"); + int64_t sleep_ms = (expectedPresentTime_->timestampNanos - timestamp - period) / (1000 * 1000); std::this_thread::sleep_for(std::chrono::milliseconds(sleep_ms)); } expectedPresentTime_ = std::nullopt; - } else { - std::this_thread::sleep_for(std::chrono::nanoseconds((int64_t)(1E9 / staged_mode_->v_refresh()) / 2)); - } + } + if (IsInHeadlessMode()) { *out_present_fence = -1; return HWC2::Error::None; @@ -957,12 +958,16 @@ HWC2::Error HwcDisplay::GetDisplayIdentificationData(uint8_t *outPort, } HWC2::Error HwcDisplay::GetDisplayCapabilities(uint32_t *outNumCapabilities, - uint32_t * /*outCapabilities*/) { + uint32_t * outCapabilities) { if (outNumCapabilities == nullptr) { return HWC2::Error::BadParameter; } - *outNumCapabilities = 0; + *outNumCapabilities = 1; + + if (outCapabilities != nullptr) { + outCapabilities[0] = 8; + } return HWC2::Error::None; }