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/drm/VSyncWorker.cpp b/drm/VSyncWorker.cpp
index 963a37b..f4c0710 100644
--- a/drm/VSyncWorker.cpp
+++ b/drm/VSyncWorker.cpp
@@ -58,6 +58,11 @@
   cv_.notify_all();
 }
 
+void VSyncWorker::SetVsyncPeriodNs(uint32_t vsync_period_ns) {
+  const std::lock_guard<std::mutex> lock(mutex_);
+  vsync_period_ns_ = vsync_period_ns;
+}
+
 void VSyncWorker::StopThread() {
   {
     const std::lock_guard<std::mutex> lock(mutex_);
@@ -97,9 +102,7 @@
 
   // Default to 60Hz refresh rate
   constexpr uint32_t kDefaultVSPeriodNs = 16666666;
-  auto period_ns = kDefaultVSPeriodNs;
-  if (callbacks_.get_vperiod_ns && callbacks_.get_vperiod_ns() != 0)
-    period_ns = callbacks_.get_vperiod_ns();
+  auto period_ns = vsync_period_ns_ ? vsync_period_ns_ : kDefaultVSPeriodNs;
 
   auto phased_timestamp = GetPhasedVSync(period_ns, time_now);
   struct timespec vsync {};