hwc2: Enable vsync upon refresh rate increase.
Sync model needs to be corrected upon refresh rate change.
While ramping up, it is necessary to ensure that first vsync
after rate change is delivered to client. Enabling it in
prepare phase can make this happen.
Client would turn on h/w vsync only after config change takes
effect ie; PostCommit. Since driver is busy in processing
current commit, it can lead to vsync miss.
CRs-Fixed: 2418977
Change-Id: Ib5d75089e89219c73c7f15167cd8ddfd8ce70c38
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index e1892da..635fb22 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -179,10 +179,23 @@
}
uint32_t refresh_rate = GetOptimalRefreshRate(one_updating_layer);
- bool final_rate = force_refresh_rate_ ? true : false;
- error = display_intf_->SetRefreshRate(refresh_rate, final_rate);
+ error = display_intf_->SetRefreshRate(refresh_rate, force_refresh_rate_);
+
+ // Get the refresh rate set.
+ display_intf_->GetRefreshRate(&refresh_rate);
+ bool vsync_source = (callbacks_->GetVsyncSource() == id_);
+
if (error == kErrorNone) {
- // On success, set current refresh rate to new refresh rate
+ if (vsync_source && (current_refresh_rate_ < refresh_rate)) {
+ DTRACE_BEGIN("HWC2::Vsync::Enable");
+ // Display is ramping up from idle.
+ // Client realizes need for resync upon change in config.
+ // Since we know config has changed, triggering vsync proactively
+ // can help in reducing pipeline delays to enable events.
+ SetVsyncEnabled(HWC2::Vsync::Enable);
+ DTRACE_END();
+ }
+ // On success, set current refresh rate to new refresh rate.
current_refresh_rate_ = refresh_rate;
}