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

Commit 77df0f49 authored by Mark Yacoub's avatar Mark Yacoub
Browse files

Get the latest hotplugs

[Why]
With VKMS, we want to test if the hwc indeed receives an hdd from the
kernel and send a hotplug event to its client when the connector status
changes.

[How]
Create a list of hotplugs that gets updated on every hotplug event
callback from the hwc. Save with its ID and connection status.
Once it's read, clear it, so the client is able to always check for the
latest since it was last read, or clear to listen to the newest one.

Bug: b/398831713, b/352790467
Test: atest hotplugs_test
Flag: TEST_ONLY
Change-Id: If90359848816e9c974858952ca117987ef1b763c
parent f33aa725
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -458,6 +458,11 @@ ComposerClientWrapper::takeListOfRefreshRateChangedDebugData() {
    return mComposerCallback->takeListOfRefreshRateChangedDebugData();
}

std::vector<std::pair<int64_t, common::DisplayHotplugEvent>>
ComposerClientWrapper::getAndClearLatestHotplugs() {
    return mComposerCallback->getAndClearLatestHotplugs();
}

int64_t ComposerClientWrapper::getInvalidDisplayId() {
    // returns an invalid display id (one that has not been registered to a
    // display. Currently assuming that a device will never have close to
+15 −0
Original line number Diff line number Diff line
@@ -100,6 +100,16 @@ int32_t GraphicsComposerCallback::getInvalidRefreshRateDebugEnabledCallbackCount
    return mInvalidRefreshRateDebugEnabledCallbackCount;
}

std::vector<std::pair<int64_t, common::DisplayHotplugEvent>>
GraphicsComposerCallback::getAndClearLatestHotplugs() {
    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> ret;
    {
        std::scoped_lock lock(mMutex);
        ret.swap(mLatestHotplugs);
    }
    return ret;
}

::ndk::ScopedAStatus GraphicsComposerCallback::onHotplug(int64_t in_display, bool in_connected) {
    std::scoped_lock lock(mMutex);

@@ -196,6 +206,11 @@ int32_t GraphicsComposerCallback::getInvalidRefreshRateDebugEnabledCallbackCount

::ndk::ScopedAStatus GraphicsComposerCallback::onHotplugEvent(int64_t in_display,
                                                              common::DisplayHotplugEvent event) {
    {
        std::scoped_lock lock(mMutex);
        mLatestHotplugs.emplace_back(in_display, event);
    }

    switch (event) {
        case common::DisplayHotplugEvent::CONNECTED:
            return onHotplug(in_display, true);
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,8 @@ class ComposerClientWrapper {
    std::pair<ScopedAStatus, std::vector<Luts>> getLuts(int64_t display,
                                                        const std::vector<Buffer>& buffers);

    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> getAndClearLatestHotplugs();

    static constexpr int32_t kMaxFrameIntervalNs = 50000000;  // 20fps
    static constexpr int32_t kNoFrameIntervalNs = 0;

+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ class GraphicsComposerCallback : public BnComposerCallback {

    int32_t getInvalidRefreshRateDebugEnabledCallbackCount() const;

    std::vector<std::pair<int64_t, common::DisplayHotplugEvent>> getAndClearLatestHotplugs();

  private:
    virtual ::ndk::ScopedAStatus onHotplug(int64_t in_display, bool in_connected) override;
    virtual ::ndk::ScopedAStatus onRefresh(int64_t in_display) override;
@@ -71,6 +73,8 @@ class GraphicsComposerCallback : public BnComposerCallback {
    mutable std::mutex mMutex;
    // the set of all currently connected displays
    std::vector<int64_t> mDisplays GUARDED_BY(mMutex);
    std::vector<std::pair<int64_t /*display id*/, common::DisplayHotplugEvent>> mLatestHotplugs
            GUARDED_BY(mMutex);
    // true only when vsync is enabled
    bool mVsyncAllowed GUARDED_BY(mMutex) = true;
    // true only when RefreshRateChangedCallbackDebugEnabled is set to true.