Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfc130a6 authored by Ram Indani's avatar Ram Indani Committed by Android (Google) Code Review
Browse files

Merge changes from topic "neptc" into main

* changes:
  [SF] Adds notifyExpectedPresent call for timeoutNs
  [SF] Adds support to call notifyExpectedPresentHint
parents 5cb8ade7 b90711b2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ public:
    MOCK_METHOD(const aidl::android::hardware::graphics::composer3::OverlayProperties&,
                getOverlaySupport, (), (const, override));
    MOCK_METHOD(status_t, setRefreshRateChangedCallbackDebugEnabled, (PhysicalDisplayId, bool));
    MOCK_METHOD(status_t, notifyExpectedPresentIfRequired,
                (PhysicalDisplayId, nsecs_t, int32_t, int32_t));
};

} // namespace mock
+14 −0
Original line number Diff line number Diff line
@@ -1450,6 +1450,20 @@ Error AidlComposer::setRefreshRateChangedCallbackDebugEnabled(Display displayId,
    return Error::NONE;
}

Error AidlComposer::notifyExpectedPresent(Display displayId, nsecs_t expectedPresentTime,
                                          int32_t frameIntervalNs) {
    const auto status =
            mAidlComposerClient->notifyExpectedPresent(translate<int64_t>(displayId),
                                                       ClockMonotonicTimestamp{expectedPresentTime},
                                                       frameIntervalNs);

    if (!status.isOk()) {
        ALOGE("notifyExpectedPresent failed %s", status.getDescription().c_str());
        return static_cast<Error>(status.getServiceSpecificError());
    }
    return Error::NONE;
}

Error AidlComposer::getClientTargetProperty(
        Display display, ClientTargetPropertyWithBrightness* outClientTargetProperty) {
    Error error = Error::NONE;
+2 −0
Original line number Diff line number Diff line
@@ -240,6 +240,8 @@ public:
    Error getHdrConversionCapabilities(std::vector<HdrConversionCapability>*) override;
    Error setHdrConversionStrategy(HdrConversionStrategy, Hdr*) override;
    Error setRefreshRateChangedCallbackDebugEnabled(Display, bool) override;
    Error notifyExpectedPresent(Display, nsecs_t expectedPresentTime,
                                int32_t frameIntervalNs) override;

private:
    // Many public functions above simply write a command into the command
+2 −0
Original line number Diff line number Diff line
@@ -298,6 +298,8 @@ public:
    virtual Error setHdrConversionStrategy(
            ::aidl::android::hardware::graphics::common::HdrConversionStrategy, Hdr*) = 0;
    virtual Error setRefreshRateChangedCallbackDebugEnabled(Display, bool) = 0;
    virtual Error notifyExpectedPresent(Display, nsecs_t expectedPresentTime,
                                        int32_t frameIntervalNs) = 0;
};

} // namespace Hwc2
+26 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <compositionengine/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
#include <ftl/concat.h>
#include <gui/TraceUtils.h>
#include <log/log.h>
#include <ui/DebugUtils.h>
#include <ui/GraphicBuffer.h>
@@ -484,6 +485,7 @@ status_t HWComposer::getDeviceCompositionChanges(
    }();

    displayData.validateWasSkipped = false;
    displayData.lastExpectedPresentTimestamp = expectedPresentTime;
    if (canSkipValidate) {
        sp<Fence> outPresentFence;
        uint32_t state = UINT32_MAX;
@@ -876,6 +878,30 @@ status_t HWComposer::setRefreshRateChangedCallbackDebugEnabled(PhysicalDisplayId
    return NO_ERROR;
}

status_t HWComposer::notifyExpectedPresentIfRequired(PhysicalDisplayId displayId,
                                                     nsecs_t expectedPresentTime,
                                                     int32_t frameIntervalNs, int32_t timeoutNs) {
    RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);

    auto& displayData = mDisplayData[displayId];
    if (expectedPresentTime >= displayData.lastExpectedPresentTimestamp &&
        expectedPresentTime < displayData.lastExpectedPresentTimestamp + timeoutNs) {
        return NO_ERROR;
    }

    displayData.lastExpectedPresentTimestamp = expectedPresentTime;
    ATRACE_FORMAT("%s ExpectedPresentTime %" PRId64 " frameIntervalNs %d", __func__,
                  expectedPresentTime, frameIntervalNs);
    const auto error = mComposer->notifyExpectedPresent(displayData.hwcDisplay->getId(),
                                                        expectedPresentTime, frameIntervalNs);

    if (error != hal::Error::NONE) {
        ALOGE("Error in notifyExpectedPresent call %s", to_string(error).c_str());
        return INVALID_OPERATION;
    }
    return NO_ERROR;
}

status_t HWComposer::getDisplayDecorationSupport(
        PhysicalDisplayId displayId,
        std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
Loading