diff options
author | Xin Li <delphij@google.com> | 2024-03-06 09:30:00 -0800 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2024-03-06 09:30:00 -0800 |
commit | b00b1a03678c6ac7792ab34327e989ab3c634bbd (patch) | |
tree | e004f1a9b525df54a6078e9327258a69f66978b2 /hwc3 | |
parent | 0c73da6ad5371340e6dc915647ec544b2e6e3f30 (diff) | |
parent | ba9c7c27619716648bb47bba27e9bca4d3596f64 (diff) | |
download | common-master.tar.gz |
Bug: 319669529
Merged-In: I64dec227d53882b7ef2d878430a81f80557a6468
Change-Id: If03895348218e16761267293a77a093dcdf4d920
Diffstat (limited to 'hwc3')
-rw-r--r-- | hwc3/Android.mk | 18 | ||||
-rw-r--r-- | hwc3/Composer.cpp | 11 | ||||
-rw-r--r-- | hwc3/Composer.h | 6 | ||||
-rw-r--r-- | hwc3/ComposerClient.cpp | 26 | ||||
-rw-r--r-- | hwc3/ComposerClient.h | 6 | ||||
-rw-r--r-- | hwc3/ComposerCommandEngine.cpp | 33 | ||||
-rw-r--r-- | hwc3/ComposerCommandEngine.h | 9 | ||||
-rw-r--r-- | hwc3/hwc3-default.xml | 2 | ||||
-rw-r--r-- | hwc3/impl/HalImpl.cpp | 80 | ||||
-rw-r--r-- | hwc3/impl/HalImpl.h | 11 | ||||
-rw-r--r-- | hwc3/include/IComposerHal.h | 44 | ||||
-rw-r--r-- | hwc3/service.cpp | 5 |
12 files changed, 197 insertions, 54 deletions
diff --git a/hwc3/Android.mk b/hwc3/Android.mk index 6358a90..38f9595 100644 --- a/hwc3/Android.mk +++ b/hwc3/Android.mk @@ -32,11 +32,11 @@ LOCAL_CFLAGS += \ -Wthread-safety # hwc3 re-uses hwc2.2 ComposerResource and libexynosdisplay -LOCAL_SHARED_LIBRARIES := android.hardware.graphics.composer3-V2-ndk \ +LOCAL_SHARED_LIBRARIES := android.hardware.graphics.composer3-V3-ndk \ android.hardware.graphics.composer@2.1-resources \ android.hardware.graphics.composer@2.2-resources \ android.hardware.graphics.composer@2.4 \ - com.google.hardware.pixel.display-V9-ndk \ + com.google.hardware.pixel.display-V10-ndk \ libbase \ libbinder \ libbinder_ndk \ @@ -86,6 +86,20 @@ LOCAL_SHARED_LIBRARIES += libExynosHWCService LOCAL_HEADER_LIBRARIES += libbinder_headers endif +ifeq ($(CLANG_COVERAGE),true) +# enable code coverage (these flags are copied from build/soong/cc/coverage.go) +LOCAL_CFLAGS += -fprofile-instr-generate -fcoverage-mapping +LOCAL_CFLAGS += -Wno-frame-larger-than= +LOCAL_WHOLE_STATIC_LIBRARIES += libprofile-clang-extras_ndk +LOCAL_LDFLAGS += -fprofile-instr-generate +LOCAL_LDFLAGS += -Wl,--wrap,open + +ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true) +LOCAL_CFLAGS += -mllvm -runtime-counter-relocation +LOCAL_LDFLAGS += -Wl,-mllvm=-runtime-counter-relocation +endif +endif + LOCAL_VINTF_FRAGMENTS = hwc3-default.xml LOCAL_INIT_RC := hwc3-pixel.rc diff --git a/hwc3/Composer.cpp b/hwc3/Composer.cpp index 4a57d96..40cadc8 100644 --- a/hwc3/Composer.cpp +++ b/hwc3/Composer.cpp @@ -25,6 +25,17 @@ namespace aidl::android::hardware::graphics::composer3::impl { +Composer::Composer() { + int32_t composerInterfaceVersion = 1; + const auto status = getInterfaceVersion(&composerInterfaceVersion); + if (!status.isOk()) { + ALOGE("Get interface version from Composer constructor failed %s", + status.getDescription().c_str()); + } + mHal = IComposerHal::create(composerInterfaceVersion); + CHECK(mHal != nullptr); +} + ndk::ScopedAStatus Composer::createClient(std::shared_ptr<IComposerClient>* outClient) { DEBUG_FUNC(); std::unique_lock<std::mutex> lock(mClientMutex); diff --git a/hwc3/Composer.h b/hwc3/Composer.h index d35c3de..5ea93a1 100644 --- a/hwc3/Composer.h +++ b/hwc3/Composer.h @@ -26,11 +26,11 @@ namespace aidl::android::hardware::graphics::composer3::impl { class Composer : public BnComposer { public: - Composer(std::unique_ptr<IComposerHal> hal) : mHal(std::move(hal)) {} + Composer(); binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; - // compser3 api + // composer3 api ndk::ScopedAStatus createClient(std::shared_ptr<IComposerClient>* client) override; ndk::ScopedAStatus getCapabilities(std::vector<Capability>* caps) override; @@ -41,7 +41,7 @@ private: bool waitForClientDestroyedLocked(std::unique_lock<std::mutex>& lock); void onClientDestroyed(); - const std::unique_ptr<IComposerHal> mHal; + std::unique_ptr<IComposerHal> mHal; std::mutex mClientMutex; bool mClientAlive = false; // GUARDED_BY(mClientMutex) std::condition_variable mClientDestroyedCondition; diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp index c34b13a..104bac6 100644 --- a/hwc3/ComposerClient.cpp +++ b/hwc3/ComposerClient.cpp @@ -20,6 +20,7 @@ #include <android-base/logging.h> #include <android/binder_ibinder_platform.h> +#include <hardware/hwcomposer2.h> #include "Util.h" @@ -76,6 +77,21 @@ ndk::ScopedAStatus ComposerClient::createVirtualDisplay(int32_t width, int32_t h return TO_BINDER_STATUS(err); } +ndk::ScopedAStatus ComposerClient::getDisplayConfigurations( + int64_t display, int32_t maxFrameIntervalNs, std::vector<DisplayConfiguration>* configs) { + DEBUG_DISPLAY_FUNC(display); + auto err = mHal->getDisplayConfigurations(display, maxFrameIntervalNs, configs); + return TO_BINDER_STATUS(err); +} + +ndk::ScopedAStatus ComposerClient::notifyExpectedPresent( + int64_t display, const ClockMonotonicTimestamp& expectedPresentTime, + int32_t frameIntervalNs) { + DEBUG_DISPLAY_FUNC(display); + auto err = mHal->notifyExpectedPresent(display, expectedPresentTime, frameIntervalNs); + return TO_BINDER_STATUS(err); +} + ndk::ScopedAStatus ComposerClient::destroyLayer(int64_t display, int64_t layer) { DEBUG_DISPLAY_FUNC(display); auto err = mHal->destroyLayer(display, layer); @@ -171,6 +187,16 @@ ndk::ScopedAStatus ComposerClient::getDisplayCapabilities(int64_t display, caps->push_back(DisplayCapability::DISPLAY_IDLE_TIMER); } + err = mHal->getDisplayMultiThreadedPresentSupport(display, support); + if (err != ::android::OK) { + LOG(ERROR) << "failed to getDisplayMultiThreadedPresentSupport: " << err; + return TO_BINDER_STATUS(err); + } + + if (support) { + caps->push_back(DisplayCapability::MULTI_THREADED_PRESENT); + } + return TO_BINDER_STATUS(err); } diff --git a/hwc3/ComposerClient.h b/hwc3/ComposerClient.h index 7a76fa4..11e0a52 100644 --- a/hwc3/ComposerClient.h +++ b/hwc3/ComposerClient.h @@ -134,6 +134,12 @@ public: ndk::ScopedAStatus setIdleTimerEnabled(int64_t display, int32_t timeout) override; ndk::ScopedAStatus setRefreshRateChangedCallbackDebugEnabled(int64_t /* display */, bool /* enabled */) override; + ndk::ScopedAStatus getDisplayConfigurations( + int64_t display, int32_t maxFrameIntervalNs, + std::vector<DisplayConfiguration>* configs) override; + ndk::ScopedAStatus notifyExpectedPresent(int64_t display, + const ClockMonotonicTimestamp& expectedPresentTime, + int32_t frameIntervalNs) override; protected: ::ndk::SpAIBinder createBinder() override; diff --git a/hwc3/ComposerCommandEngine.cpp b/hwc3/ComposerCommandEngine.cpp index eac4df2..32ad027 100644 --- a/hwc3/ComposerCommandEngine.cpp +++ b/hwc3/ComposerCommandEngine.cpp @@ -51,11 +51,11 @@ namespace aidl::android::hardware::graphics::composer3::impl { } \ } while (0) -#define DISPATCH_DISPLAY_BOOL_COMMAND_AND_DATA(displayCmd, field, data, funcName) \ - do { \ - if (displayCmd.field) { \ - execute##funcName(displayCmd.display, displayCmd.data); \ - } \ +#define DISPATCH_DISPLAY_COMMAND_AND_TWO_DATA(displayCmd, field, data_1, data_2, funcName) \ + do { \ + if (displayCmd.field) { \ + execute##funcName(displayCmd.display, displayCmd.data_1, displayCmd.data_2); \ + } \ } while (0) int32_t ComposerCommandEngine::init() { @@ -104,12 +104,12 @@ void ComposerCommandEngine::dispatchDisplayCommand(const DisplayCommand& command DISPATCH_DISPLAY_COMMAND(command, colorTransformMatrix, SetColorTransform); DISPATCH_DISPLAY_COMMAND(command, clientTarget, SetClientTarget); DISPATCH_DISPLAY_COMMAND(command, virtualDisplayOutputBuffer, SetOutputBuffer); - DISPATCH_DISPLAY_BOOL_COMMAND_AND_DATA(command, validateDisplay, expectedPresentTime, - ValidateDisplay); + DISPATCH_DISPLAY_COMMAND_AND_TWO_DATA(command, validateDisplay, expectedPresentTime, + frameIntervalNs, ValidateDisplay); DISPATCH_DISPLAY_BOOL_COMMAND(command, acceptDisplayChanges, AcceptDisplayChanges); DISPATCH_DISPLAY_BOOL_COMMAND(command, presentDisplay, PresentDisplay); - DISPATCH_DISPLAY_BOOL_COMMAND_AND_DATA(command, presentOrValidateDisplay, expectedPresentTime, - PresentOrValidateDisplay); + DISPATCH_DISPLAY_COMMAND_AND_TWO_DATA(command, presentOrValidateDisplay, expectedPresentTime, + frameIntervalNs, PresentOrValidateDisplay); } void ComposerCommandEngine::dispatchLayerCommand(int64_t display, const LayerCommand& command) { @@ -213,13 +213,15 @@ void ComposerCommandEngine::executeSetOutputBuffer(uint64_t display, const Buffe } void ComposerCommandEngine::executeSetExpectedPresentTimeInternal( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) { - mHal->setExpectedPresentTime(display, expectedPresentTime); + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) { + mHal->setExpectedPresentTime(display, expectedPresentTime, frameIntervalNs); } void ComposerCommandEngine::executeValidateDisplay( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) { - executeSetExpectedPresentTimeInternal(display, expectedPresentTime); + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) { + executeSetExpectedPresentTimeInternal(display, expectedPresentTime, frameIntervalNs); executeValidateDisplayInternal(display); } @@ -233,8 +235,9 @@ void ComposerCommandEngine::executeSetDisplayBrightness(uint64_t display, } void ComposerCommandEngine::executePresentOrValidateDisplay( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) { - executeSetExpectedPresentTimeInternal(display, expectedPresentTime); + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) { + executeSetExpectedPresentTimeInternal(display, expectedPresentTime, frameIntervalNs); // First try to Present as is. auto presentErr = mResources->mustValidateDisplay(display) ? IComposerClient::EX_NOT_VALIDATED : executePresentDisplay(display); diff --git a/hwc3/ComposerCommandEngine.h b/hwc3/ComposerCommandEngine.h index 872c7e5..1ec110e 100644 --- a/hwc3/ComposerCommandEngine.h +++ b/hwc3/ComposerCommandEngine.h @@ -52,9 +52,11 @@ class ComposerCommandEngine { void executeSetDisplayBrightness(uint64_t display, const DisplayBrightness& command); void executeSetOutputBuffer(uint64_t display, const Buffer& buffer); void executeValidateDisplay(int64_t display, - const std::optional<ClockMonotonicTimestamp> expectedPresentTime); + const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs); void executePresentOrValidateDisplay( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime); + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs); void executeAcceptDisplayChanges(int64_t display); int executePresentDisplay(int64_t display); @@ -94,7 +96,8 @@ class ComposerCommandEngine { int32_t executeValidateDisplayInternal(int64_t display); void executeSetExpectedPresentTimeInternal( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime); + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs); IComposerHal* mHal; IResourceManager* mResources; diff --git a/hwc3/hwc3-default.xml b/hwc3/hwc3-default.xml index fd9e638..911f7f8 100644 --- a/hwc3/hwc3-default.xml +++ b/hwc3/hwc3-default.xml @@ -1,7 +1,7 @@ <manifest version="1.0" type="device"> <hal format="aidl"> <name>android.hardware.graphics.composer3</name> - <version>2</version> + <version>3</version> <interface> <name>IComposer</name> <instance>default</instance> diff --git a/hwc3/impl/HalImpl.cpp b/hwc3/impl/HalImpl.cpp index d8fe206..37e7d9f 100644 --- a/hwc3/impl/HalImpl.cpp +++ b/hwc3/impl/HalImpl.cpp @@ -30,14 +30,20 @@ using namespace SOC_VERSION; +namespace { + +static constexpr int32_t kMinComposerInterfaceVersionForVrrApi = 3; + +}; + namespace aidl::android::hardware::graphics::composer3::impl { -std::unique_ptr<IComposerHal> IComposerHal::create() { - auto device = std::make_unique<ExynosDeviceModule>(); +std::unique_ptr<IComposerHal> IComposerHal::create(int32_t composerInterfaceVersion) { + bool vrrApiSupported = composerInterfaceVersion >= kMinComposerInterfaceVersionForVrrApi; + auto device = std::make_unique<ExynosDeviceModule>(vrrApiSupported); if (!device) { return nullptr; } - return std::make_unique<HalImpl>(std::move(device)); } @@ -107,9 +113,11 @@ void refreshRateChangedDebug(hwc2_callback_data_t callbackData, hwc2_display_t h h2a::translate(hwcDisplay, display); h2a::translate(hwcVsyncPeriodNanos, vsyncPeriodNanos); + // TODO (b/314527560) Update refreshPeriodNanos for VRR display hal->getEventCallback()->onRefreshRateChangedDebug(RefreshRateChangedDebugData{ .display = display, .vsyncPeriodNanos = vsyncPeriodNanos, + .refreshPeriodNanos = vsyncPeriodNanos, }); } @@ -373,6 +381,67 @@ int32_t HalImpl::getDisplayConfigs(int64_t display, std::vector<int32_t>* config return HWC2_ERROR_NONE; } +int32_t HalImpl::getDisplayConfigurations(int64_t display, int32_t, + std::vector<DisplayConfiguration>* outConfigs) { + ExynosDisplay* halDisplay; + RET_IF_ERR(getHalDisplay(display, halDisplay)); + + std::vector<int32_t> configIds; + RET_IF_ERR(getDisplayConfigs(display, &configIds)); + + for (const auto configId : configIds) { + DisplayConfiguration config; + config.configId = configId; + // Get required display attributes + RET_IF_ERR(getDisplayAttribute(display, configId, DisplayAttribute::WIDTH, &config.width)); + RET_IF_ERR( + getDisplayAttribute(display, configId, DisplayAttribute::HEIGHT, &config.height)); + RET_IF_ERR(getDisplayAttribute(display, configId, DisplayAttribute::VSYNC_PERIOD, + &config.vsyncPeriod)); + RET_IF_ERR(getDisplayAttribute(display, configId, DisplayAttribute::CONFIG_GROUP, + &config.configGroup)); + // Get optional display attributes + int32_t dpiX, dpiY; + auto statusDpiX = getDisplayAttribute(display, configId, DisplayAttribute::DPI_X, &dpiX); + auto statusDpiY = getDisplayAttribute(display, configId, DisplayAttribute::DPI_Y, &dpiY); + // TODO(b/294120341): getDisplayAttribute for DPI should return dots per inch + if (statusDpiX == HWC2_ERROR_NONE && statusDpiY == HWC2_ERROR_NONE) { + config.dpi = {dpiX / 1000.0f, dpiY / 1000.0f}; + } + // Determine whether there is a need to configure VRR. + hwc2_config_t hwcConfigId; + a2h::translate(configId, hwcConfigId); + std::optional<VrrConfig_t> vrrConfig = halDisplay->getVrrConfigs(hwcConfigId); + if (vrrConfig.has_value()) { + // TODO(b/290843234): complete the remaining values within vrrConfig. + VrrConfig hwc3VrrConfig; + VrrConfig::NotifyExpectedPresentConfig notifyExpectedPresentConfig; + hwc3VrrConfig.minFrameIntervalNs = vrrConfig->minFrameIntervalNs; + notifyExpectedPresentConfig.notifyExpectedPresentHeadsUpNs = + vrrConfig->notifyExpectedPresentConfig.HeadsUpNs; + notifyExpectedPresentConfig.notifyExpectedPresentTimeoutNs = + vrrConfig->notifyExpectedPresentConfig.TimeoutNs; + hwc3VrrConfig.notifyExpectedPresentConfig = + std::make_optional(notifyExpectedPresentConfig); + config.vrrConfig = std::make_optional(hwc3VrrConfig); + } + outConfigs->push_back(config); + } + + return HWC2_ERROR_NONE; +} + +int32_t HalImpl::notifyExpectedPresent(int64_t display, + const ClockMonotonicTimestamp& expectedPresentTime, + int32_t frameIntervalNs) { + ExynosDisplay* halDisplay; + RET_IF_ERR(getHalDisplay(display, halDisplay)); + + RET_IF_ERR( + halDisplay->notifyExpectedPresent(expectedPresentTime.timestampNanos, frameIntervalNs)); + return HWC2_ERROR_NONE; +} + int32_t HalImpl::getDisplayConnectionType(int64_t display, DisplayConnectionType* outType) { ExynosDisplay* halDisplay; RET_IF_ERR(getHalDisplay(display, halDisplay)); @@ -1045,7 +1114,8 @@ int32_t HalImpl::validateDisplay(int64_t display, std::vector<int64_t>* outChang } int HalImpl::setExpectedPresentTime( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) { + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) { ExynosDisplay* halDisplay; RET_IF_ERR(getHalDisplay(display, halDisplay)); @@ -1055,7 +1125,7 @@ int HalImpl::setExpectedPresentTime( ALOGW("HalImpl: set expected present time multiple times in one frame"); } - halDisplay->setExpectedPresentTime(expectedPresentTime->timestampNanos); + halDisplay->setExpectedPresentTime(expectedPresentTime->timestampNanos, frameIntervalNs); return HWC2_ERROR_NONE; } diff --git a/hwc3/impl/HalImpl.h b/hwc3/impl/HalImpl.h index 9822ff7..6a0108a 100644 --- a/hwc3/impl/HalImpl.h +++ b/hwc3/impl/HalImpl.h @@ -60,6 +60,11 @@ class HalImpl : public IComposerHal { int32_t getDisplayBrightnessSupport(int64_t display, bool& outSupport) override; int32_t getDisplayCapabilities(int64_t display, std::vector<DisplayCapability>* caps) override; int32_t getDisplayConfigs(int64_t display, std::vector<int32_t>* configs) override; + int32_t getDisplayConfigurations(int64_t display, int32_t maxFrameIntervalNs, + std::vector<DisplayConfiguration>* outConfigs) override; + int32_t notifyExpectedPresent(int64_t display, + const ClockMonotonicTimestamp& expectedPresentTime, + int32_t frameIntervalNs) override; int32_t getDisplayConnectionType(int64_t display, DisplayConnectionType* outType) override; int32_t getDisplayIdentificationData(int64_t display, DisplayIdentification* id) override; int32_t getDisplayName(int64_t display, std::string* outName) override; @@ -154,9 +159,9 @@ class HalImpl : public IComposerHal { std::vector<int32_t>* outRequestMasks, ClientTargetProperty* outClientTargetProperty, DimmingStage* outDimmingStage) override; - int32_t setExpectedPresentTime( - int64_t display, - const std::optional<ClockMonotonicTimestamp> expectedPresentTime) override; + int32_t setExpectedPresentTime(int64_t display, + const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) override; EventCallback* getEventCallback() { return mEventCallback; } int32_t setRefreshRateChangedCallbackDebugEnabled(int64_t display, bool enabled) override; diff --git a/hwc3/include/IComposerHal.h b/hwc3/include/IComposerHal.h index 93dda20..2387973 100644 --- a/hwc3/include/IComposerHal.h +++ b/hwc3/include/IComposerHal.h @@ -49,6 +49,7 @@ #include <aidl/android/hardware/graphics/composer3/DisplayBrightness.h> #include <aidl/android/hardware/graphics/composer3/DisplayCapability.h> #include <aidl/android/hardware/graphics/composer3/DisplayCommand.h> +#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h> #include <aidl/android/hardware/graphics/composer3/DisplayConnectionType.h> #include <aidl/android/hardware/graphics/composer3/DisplayContentSample.h> #include <aidl/android/hardware/graphics/composer3/DisplayContentSamplingAttributes.h> @@ -83,6 +84,7 @@ // avoid naming conflict using AidlPixelFormat = aidl::android::hardware::graphics::common::PixelFormat; using AidlNativeHandle = aidl::android::hardware::common::NativeHandle; +using DisplayConfiguration = aidl::android::hardware::graphics::composer3::DisplayConfiguration; namespace aidl::android::hardware::graphics::composer3::impl { @@ -90,25 +92,25 @@ namespace aidl::android::hardware::graphics::composer3::impl { // IComposerClient interface. class IComposerHal { public: - static std::unique_ptr<IComposerHal> create(); - virtual ~IComposerHal() = default; + static std::unique_ptr<IComposerHal> create(int32_t composerInterfaceVersion); + virtual ~IComposerHal() = default; - virtual void getCapabilities(std::vector<Capability>* caps) = 0; - virtual void dumpDebugInfo(std::string* output) = 0; - virtual bool hasCapability(Capability cap) = 0; + virtual void getCapabilities(std::vector<Capability>* caps) = 0; + virtual void dumpDebugInfo(std::string* output) = 0; + virtual bool hasCapability(Capability cap) = 0; - class EventCallback { - public: - virtual ~EventCallback() = default; - virtual void onHotplug(int64_t display, bool connected) = 0; - virtual void onRefresh(int64_t display) = 0; - virtual void onVsync(int64_t display, int64_t timestamp, int32_t vsyncPeriodNanos) = 0; - virtual void onVsyncPeriodTimingChanged(int64_t display, - const VsyncPeriodChangeTimeline& timeline) = 0; - virtual void onVsyncIdle(int64_t display) = 0; - virtual void onSeamlessPossible(int64_t display) = 0; - virtual void onRefreshRateChangedDebug(const RefreshRateChangedDebugData& data) = 0; - }; + class EventCallback { + public: + virtual ~EventCallback() = default; + virtual void onHotplug(int64_t display, bool connected) = 0; + virtual void onRefresh(int64_t display) = 0; + virtual void onVsync(int64_t display, int64_t timestamp, int32_t vsyncPeriodNanos) = 0; + virtual void onVsyncPeriodTimingChanged(int64_t display, + const VsyncPeriodChangeTimeline& timeline) = 0; + virtual void onVsyncIdle(int64_t display) = 0; + virtual void onSeamlessPossible(int64_t display) = 0; + virtual void onRefreshRateChangedDebug(const RefreshRateChangedDebugData& data) = 0; + }; virtual void registerEventCallback(EventCallback* callback) = 0; virtual void unregisterEventCallback() = 0; @@ -132,6 +134,11 @@ class IComposerHal { virtual int32_t getDisplayCapabilities(int64_t display, std::vector<DisplayCapability>* caps) = 0; virtual int32_t getDisplayConfigs(int64_t display, std::vector<int32_t>* configs) = 0; + virtual int32_t getDisplayConfigurations(int64_t display, int32_t maxFrameIntervalNs, + std::vector<DisplayConfiguration>* configs) = 0; + virtual int32_t notifyExpectedPresent(int64_t display, + const ClockMonotonicTimestamp& expectedPresentTime, + int32_t frameIntervalNs) = 0; virtual int32_t getDisplayConnectionType(int64_t display, DisplayConnectionType* outType) = 0; virtual int32_t getDisplayIdentificationData(int64_t display, DisplayIdentification *id) = 0; virtual int32_t getDisplayName(int64_t display, std::string* outName) = 0; @@ -226,7 +233,8 @@ class IComposerHal { ClientTargetProperty* outClientTargetProperty, DimmingStage* outDimmingStage) = 0; virtual int32_t setExpectedPresentTime( - int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime) = 0; + int64_t display, const std::optional<ClockMonotonicTimestamp> expectedPresentTime, + int frameIntervalNs) = 0; virtual int32_t setIdleTimerEnabled(int64_t display, int32_t timeout) = 0; virtual int32_t getRCDLayerSupport(int64_t display, bool& outSupport) = 0; virtual int32_t setLayerBlockingRegion( diff --git a/hwc3/service.cpp b/hwc3/service.cpp index 9269470..4b5fb1a 100644 --- a/hwc3/service.cpp +++ b/hwc3/service.cpp @@ -40,10 +40,7 @@ int main(int /*argc*/, char* argv[]) { LOG(ERROR) << "Couldn't set SCHED_FIFO: " << errno; } - std::unique_ptr<IComposerHal> halImpl = IComposerHal::create(); - CHECK(halImpl != nullptr); - - std::shared_ptr<Composer> composer = ndk::SharedRefBase::make<Composer>(std::move(halImpl)); + std::shared_ptr<Composer> composer = ndk::SharedRefBase::make<Composer>(); CHECK(composer != nullptr); const std::string instance = std::string() + Composer::descriptor + "/default"; |