Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -889,6 +889,7 @@ RefreshRateConfigs::KernelIdleTimerAction RefreshRateConfigs::getIdleTimerAction const auto& deviceMin = *mMinSupportedRefreshRate; const auto& minByPolicy = getMinRefreshRateByPolicyLocked(); const auto& maxByPolicy = getMaxRefreshRateByPolicyLocked(); const auto& currentPolicy = getCurrentPolicyLocked(); // Kernel idle timer will set the refresh rate to the device min. If DisplayManager says that // the min allowed refresh rate is higher than the device min, we do not want to enable the Loading @@ -897,6 +898,10 @@ RefreshRateConfigs::KernelIdleTimerAction RefreshRateConfigs::getIdleTimerAction return RefreshRateConfigs::KernelIdleTimerAction::TurnOff; } if (minByPolicy == maxByPolicy) { // when min primary range in display manager policy is below device min turn on the timer. if (currentPolicy->primaryRange.min.lessThanWithMargin(deviceMin.getFps())) { return RefreshRateConfigs::KernelIdleTimerAction::TurnOn; } return RefreshRateConfigs::KernelIdleTimerAction::TurnOff; } // Turn on the timer in all other cases. Loading services/surfaceflinger/Scheduler/RefreshRateConfigs.h +1 −2 Original line number Diff line number Diff line Loading @@ -326,8 +326,7 @@ public: return mRefreshRates.size() > 1; } // Class to enumerate options around toggling the kernel timer on and off. We have an option // for no change to avoid extra calls to kernel. // Class to enumerate options around toggling the kernel timer on and off. enum class KernelIdleTimerAction { TurnOff, // Turn off the idle timer. TurnOn // Turn on the idle timer. Loading services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -2066,6 +2066,35 @@ TEST_F(RefreshRateConfigsTest, testKernelIdleTimerAction) { EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); } TEST_F(RefreshRateConfigsTest, testKernelIdleTimerActionFor120Hz) { using KernelIdleTimerAction = scheduler::RefreshRateConfigs::KernelIdleTimerAction; // Tests with 120Hz auto refreshRateConfigs = std::make_unique<RefreshRateConfigs>(m60_120Device, /*currentConfigId=*/HWC_CONFIG_ID_120); // SetPolicy(0, 60), current 60Hz => TurnOn. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(0), Fps(60)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOn, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(60, 60), current 60Hz => TurnOff. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(60), Fps(60)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(60, 120), current 60Hz => TurnOn. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(60), Fps(120)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOn, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(120, 120), current 120Hz => TurnOff. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy( {HWC_CONFIG_ID_120, {Fps(120), Fps(120)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); } TEST_F(RefreshRateConfigsTest, getFrameRateDivider) { auto refreshRateConfigs = std::make_unique<RefreshRateConfigs>(m30_60_72_90_120Device, Loading Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -889,6 +889,7 @@ RefreshRateConfigs::KernelIdleTimerAction RefreshRateConfigs::getIdleTimerAction const auto& deviceMin = *mMinSupportedRefreshRate; const auto& minByPolicy = getMinRefreshRateByPolicyLocked(); const auto& maxByPolicy = getMaxRefreshRateByPolicyLocked(); const auto& currentPolicy = getCurrentPolicyLocked(); // Kernel idle timer will set the refresh rate to the device min. If DisplayManager says that // the min allowed refresh rate is higher than the device min, we do not want to enable the Loading @@ -897,6 +898,10 @@ RefreshRateConfigs::KernelIdleTimerAction RefreshRateConfigs::getIdleTimerAction return RefreshRateConfigs::KernelIdleTimerAction::TurnOff; } if (minByPolicy == maxByPolicy) { // when min primary range in display manager policy is below device min turn on the timer. if (currentPolicy->primaryRange.min.lessThanWithMargin(deviceMin.getFps())) { return RefreshRateConfigs::KernelIdleTimerAction::TurnOn; } return RefreshRateConfigs::KernelIdleTimerAction::TurnOff; } // Turn on the timer in all other cases. Loading
services/surfaceflinger/Scheduler/RefreshRateConfigs.h +1 −2 Original line number Diff line number Diff line Loading @@ -326,8 +326,7 @@ public: return mRefreshRates.size() > 1; } // Class to enumerate options around toggling the kernel timer on and off. We have an option // for no change to avoid extra calls to kernel. // Class to enumerate options around toggling the kernel timer on and off. enum class KernelIdleTimerAction { TurnOff, // Turn off the idle timer. TurnOn // Turn on the idle timer. Loading
services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +29 −0 Original line number Diff line number Diff line Loading @@ -2066,6 +2066,35 @@ TEST_F(RefreshRateConfigsTest, testKernelIdleTimerAction) { EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); } TEST_F(RefreshRateConfigsTest, testKernelIdleTimerActionFor120Hz) { using KernelIdleTimerAction = scheduler::RefreshRateConfigs::KernelIdleTimerAction; // Tests with 120Hz auto refreshRateConfigs = std::make_unique<RefreshRateConfigs>(m60_120Device, /*currentConfigId=*/HWC_CONFIG_ID_120); // SetPolicy(0, 60), current 60Hz => TurnOn. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(0), Fps(60)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOn, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(60, 60), current 60Hz => TurnOff. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(60), Fps(60)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(60, 120), current 60Hz => TurnOn. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_60, {Fps(60), Fps(120)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOn, refreshRateConfigs->getIdleTimerAction()); // SetPolicy(120, 120), current 120Hz => TurnOff. ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy( {HWC_CONFIG_ID_120, {Fps(120), Fps(120)}}), 0); EXPECT_EQ(KernelIdleTimerAction::TurnOff, refreshRateConfigs->getIdleTimerAction()); } TEST_F(RefreshRateConfigsTest, getFrameRateDivider) { auto refreshRateConfigs = std::make_unique<RefreshRateConfigs>(m30_60_72_90_120Device, Loading