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

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

Merge "Add a flag to control the VRR hint for timeout" into main

parents fddf2914 355fca87
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ using aidl::android::hardware::graphics::common::HdrConversionCapability;
using aidl::android::hardware::graphics::common::HdrConversionStrategy;
using aidl::android::hardware::graphics::composer3::Capability;
using aidl::android::hardware::graphics::composer3::DisplayCapability;
using aidl::android::hardware::graphics::composer3::VrrConfig;
using namespace std::string_literals;
namespace hal = android::hardware::graphics::composer::hal;

namespace android {
@@ -89,7 +91,8 @@ HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer)
      : mComposer(std::move(composer)),
        mMaxVirtualDisplayDimension(static_cast<size_t>(sysprop::max_virtual_display_dimension(0))),
        mUpdateDeviceProductInfoOnHotplugReconnect(
                sysprop::update_device_product_info_on_hotplug_reconnect(false)) {}
                sysprop::update_device_product_info_on_hotplug_reconnect(false)),
        mEnableVrrTimeout(base::GetBoolProperty("debug.sf.vrr_timeout_hint_enabled"s, false)) {}

HWComposer::HWComposer(const std::string& composerServiceName)
      : HWComposer(Hwc2::Composer::create(composerServiceName)) {}
@@ -299,6 +302,10 @@ std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromDisplayConfigura
            hwcMode.dpiY = config.dpi->y;
        }

        if (!mEnableVrrTimeout) {
            hwcMode.vrrConfig->notifyExpectedPresentConfig = {};
        }

        modes.push_back(hwcMode);
    }

+2 −0
Original line number Diff line number Diff line
@@ -491,6 +491,7 @@ public:
private:
    // For unit tests
    friend TestableSurfaceFlinger;
    friend HWComposerTest;

    struct DisplayData {
        std::unique_ptr<HWC2::Display> hwcDisplay;
@@ -542,6 +543,7 @@ private:

    const size_t mMaxVirtualDisplayDimension;
    const bool mUpdateDeviceProductInfoOnHotplugReconnect;
    bool mEnableVrrTimeout;
};

} // namespace impl
+11 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#undef LOG_TAG
#define LOG_TAG "LibSurfaceFlingerUnittests"

#include <optional>
#include <vector>

// StrictMock<T> derives from T and is not marked final, so the destructor of T is expected to be
@@ -82,6 +83,8 @@ struct HWComposerTest : testing::Test {
        EXPECT_CALL(*mHal, setVsyncEnabled(hwcDisplayId, Hwc2::IComposerClient::Vsync::DISABLE));
        EXPECT_CALL(*mHal, onHotplugConnect(hwcDisplayId));
    }

    void setVrrTimeoutHint(bool status) { mHwc.mEnableVrrTimeout = status; }
};

TEST_F(HWComposerTest, isHeadless) {
@@ -323,6 +326,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
        EXPECT_TRUE(mHwc.getModes(info->id, kMaxFrameIntervalNs).empty());
    }
    {
        setVrrTimeoutHint(true);
        constexpr int32_t kWidth = 480;
        constexpr int32_t kHeight = 720;
        constexpr int32_t kConfigGroup = 1;
@@ -361,7 +365,7 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
        displayConfiguration.dpi = {kDpi, kDpi};

        EXPECT_CALL(*mHal, getDisplayConfigurations(kHwcDisplayId, _, _))
                .WillOnce(DoAll(SetArgPointee<2>(std::vector<hal::DisplayConfiguration>{
                .WillRepeatedly(DoAll(SetArgPointee<2>(std::vector<hal::DisplayConfiguration>{
                                              displayConfiguration}),
                                      Return(HalError::NONE)));

@@ -375,6 +379,10 @@ TEST_F(HWComposerTest, getModesWithDisplayConfigurations_VRR_ON) {
        EXPECT_EQ(modes.front().vrrConfig, vrrConfig);
        EXPECT_EQ(modes.front().dpiX, kDpi);
        EXPECT_EQ(modes.front().dpiY, kDpi);

        setVrrTimeoutHint(false);
        modes = mHwc.getModes(info->id, kMaxFrameIntervalNs);
        EXPECT_EQ(modes.front().vrrConfig->notifyExpectedPresentConfig, std::nullopt);
    }
}