composer: Implement QsyncCallback API
Add change to implement qsync callback API to report change in
qsync enable/disable status and the current refresh rate/qsync
refresh rate to the client.
Change-Id: Iecc2bf9ec7af399a2556e067c92f79b8eab134af
CRs-Fixed: 2572378
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index 439170a..f40bbf4 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -296,6 +296,44 @@
return HWC2::Error::None;
}
+void HWCDisplayBuiltIn::CacheAvrStatus() {
+ QSyncMode qsync_mode = kQSyncModeNone;
+
+ DisplayError error = display_intf_->GetQSyncMode(&qsync_mode);
+ if (error != kErrorNone) {
+ return;
+ }
+
+ bool qsync_enabled = (qsync_mode != kQSyncModeNone);
+ if (qsync_enabled_ != qsync_enabled) {
+ qsync_reconfigured_ = true;
+ qsync_enabled_ = qsync_enabled;
+ } else {
+ qsync_reconfigured_ = false;
+ }
+}
+
+bool HWCDisplayBuiltIn::IsQsyncCallbackNeeded(bool *qsync_enabled, int32_t *refresh_rate,
+ int32_t *qsync_refresh_rate) {
+ if (!qsync_reconfigured_) {
+ return false;
+ }
+
+ bool vsync_source = (callbacks_->GetVsyncSource() == id_);
+ // Qsync callback not needed if this display is not the source of vsync
+ if (!vsync_source) {
+ return false;
+ }
+
+ *qsync_enabled = qsync_enabled_;
+ uint32_t current_rate = 0;
+ display_intf_->GetRefreshRate(¤t_rate);
+ *refresh_rate = INT32(current_rate);
+ *qsync_refresh_rate = min_refresh_rate_;
+
+ return true;
+}
+
HWC2::Error HWCDisplayBuiltIn::Present(int32_t *out_retire_fence) {
auto status = HWC2::Error::None;
@@ -310,6 +348,8 @@
DLOGE("Flush failed. Error = %d", error);
}
} else {
+ CacheAvrStatus();
+
status = CommitStitchLayers();
if (status != HWC2::Error::None) {
DLOGE("Stitch failed: %d", status);