drm_hwcomposer: Deprecate usage of HWC2 GetDisplayVsyncPeriod
Add an interface to HwcDisplay to query which HwcDisplayConfig is
currently committed in the kernel. Use this to implement
getDisplayVsyncPeriod.
Change-Id: Ie57759f22c012ab331ad0187043a4bea598cba78
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 51694c2..0ab43f9 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -96,6 +96,14 @@
Deinit();
};
+const HwcDisplayConfig *HwcDisplay::GetCurrentConfig() const {
+ auto config_iter = configs_.hwc_configs.find(configs_.active_config_id);
+ if (config_iter == configs_.hwc_configs.end()) {
+ return nullptr;
+ }
+ return &config_iter->second;
+}
+
void HwcDisplay::SetPipeline(std::shared_ptr<DrmDisplayPipeline> pipeline) {
Deinit();
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index 4680ca9..7cdc0b8 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -59,6 +59,9 @@
return configs_;
}
+ // Get the config representing the mode that has been committed to KMS.
+ const HwcDisplayConfig *GetCurrentConfig() const;
+
// HWC2 Hooks - these should not be used outside of the hwc2 device.
HWC2::Error AcceptDisplayChanges();
HWC2::Error CreateLayer(hwc2_layer_t *layer);
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 87ec006..7e9b88b 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -883,14 +883,15 @@
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
- uint32_t hwc2_vsync_period = 0;
- auto error = Hwc2toHwc3Error(
- display->GetDisplayVsyncPeriod(&hwc2_vsync_period));
- if (error != hwc3::Error::kNone) {
- return ToBinderStatus(error);
+ // getDisplayVsyncPeriod should return the vsync period of the config that
+ // is currently committed to the kernel. If a config change is pending due to
+ // setActiveConfigWithConstraints, return the pre-change vsync period.
+ const HwcDisplayConfig* config = display->GetCurrentConfig();
+ if (config == nullptr) {
+ return ToBinderStatus(hwc3::Error::kBadConfig);
}
- *vsync_period = static_cast<int32_t>(hwc2_vsync_period);
+ *vsync_period = config->mode.GetVSyncPeriodNs();
return ndk::ScopedAStatus::ok();
}