drm_hwcomposer: Set vsync period for vsync thread
Make HwcDisplay set the VsyncWorker's vsync_period whenever it changes,
rather than having VsyncWorker query the vsync_period from HwcDisplay.
Doing so prevents the VsyncWorker thread from needing to acquire the
global lock to read HwcDisplay's state.
The original change called GetVsyncPeriod, which checks the vsync period
for the mode that is currently committed to the kernel based on
HwcDisplay::configs_.active_config_id, so call
VsyncWorker::SetVsyncPeriod whenever active_config_id is set.
Change-Id: Ie301c47e2496748117db8cca8a6ee9691e723c74
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 0503f39..6b676c2 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -232,6 +232,8 @@
ALOGV("Blocking config succeeded.");
configs_.active_config_id = config;
staged_mode_config_id_.reset();
+ vsync_worker_->SetVsyncPeriodNs(new_config->mode.GetVSyncPeriodNs());
+ // set new vsync period
return ConfigError::kNone;
}
@@ -329,11 +331,6 @@
vsync_worker_->VSyncControl(false);
}
},
- .get_vperiod_ns = [this]() -> uint32_t {
- uint32_t outVsyncPeriod = 0;
- GetDisplayVsyncPeriod(&outVsyncPeriod);
- return outVsyncPeriod;
- },
};
if (type_ != HWC2::DisplayType::Virtual) {
@@ -698,6 +695,7 @@
.bottom = int(staged_config->mode.GetRawMode().vdisplay)});
configs_.active_config_id = staged_mode_config_id_.value();
+ vsync_worker_->SetVsyncPeriodNs(staged_config->mode.GetVSyncPeriodNs());
a_args.display_mode = staged_config->mode;
if (!a_args.test_only) {