Move toggling of kernel idle timer to SF
Idle timer is toggled from the SF code using the following logic:
- If the device policy refresh rate min = max, we turn off the timer.
- If the device policy refresh rate min > the device min,
we turn off the timer.
- Do not toggle the timer if deviceMin == policyMin.
- Timer is on in all other cases.
Bug: 140204874
Bug: 158012424
Bug: 145561154
Test: atest SurfaceFlinger_test
Test: atest libsurfaceflinger_unittest
Test: Select force 90hz through Developer Settings. Toggles timer off.
Test: Low brightness zone. Toggles timer off.
Change-Id: I9858765861a3b13e11c3930be8f77d85dae6c0c0
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
index 584a5e7..8a51b85 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
@@ -82,6 +82,8 @@
return configId != other.configId || hwcConfig != other.hwcConfig;
}
+ bool operator<(const RefreshRate& other) const { return getFps() < other.getFps(); }
+
bool operator==(const RefreshRate& other) const { return !(*this != other); }
private:
@@ -271,6 +273,17 @@
RefreshRateConfigs(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs,
HwcConfigIndexType currentConfigId);
+ // 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.
+ enum class KernelIdleTimerAction {
+ NoChange, // Do not change the idle timer.
+ TurnOff, // Turn off the idle timer.
+ TurnOn // Turn on the idle timer.
+ };
+ // Checks whether kernel idle timer should be active depending the policy decisions around
+ // refresh rates.
+ KernelIdleTimerAction getIdleTimerAction() const;
+
private:
friend class RefreshRateConfigsTest;