Merge "hwc2: Couple SetActiveConfig to commit" into display.lnx.5.1
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 4e00714..0fbf32f 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -1124,7 +1124,12 @@
return HWC2::Error::BadDisplay;
}
- GetActiveDisplayConfig(out_config);
+ if (pending_config_) {
+ *out_config = pending_config_index_;
+ } else {
+ GetActiveDisplayConfig(out_config);
+ }
+
if (*out_config < hwc_config_map_.size()) {
*out_config = hwc_config_map_.at(*out_config);
}
@@ -1162,13 +1167,22 @@
HWC2::Error HWCDisplay::SetActiveConfig(hwc2_config_t config) {
DTRACE_SCOPED();
-
- if (SetActiveDisplayConfig(config) != kErrorNone) {
- return HWC2::Error::BadConfig;
+ hwc2_config_t current_config = 0;
+ GetActiveConfig(¤t_config);
+ if (current_config == config) {
+ return HWC2::Error::None;
}
- DLOGI("Active configuration changed to: %d", config);
+
+ // Store config index to be applied upon refresh.
+ pending_config_ = true;
+ pending_config_index_ = config;
+
validated_ = false;
geometry_changes_ |= kConfigChanged;
+
+ // Trigger refresh. This config gets applied on next commit.
+ callbacks_->Refresh(id_);
+
return HWC2::Error::None;
}
@@ -1267,6 +1281,7 @@
}
UpdateRefreshRate();
+ UpdateActiveConfig();
DisplayError error = display_intf_->Prepare(&layer_stack_);
if (error != kErrorNone) {
if (error == kErrorShutDown) {
@@ -2384,5 +2399,18 @@
layer_map_ = stack->layer_map;
layer_set_ = stack->layer_set;
}
+void HWCDisplay::UpdateActiveConfig() {
+ if (!pending_config_) {
+ return;
+ }
+
+ DisplayError error = display_intf_->SetActiveConfig(pending_config_index_);
+ if (error != kErrorNone) {
+ DLOGI("Failed to set %d config", INT(pending_config_index_));
+ }
+
+ // Reset pending config.
+ pending_config_ = false;
+}
} // namespace sdm
diff --git a/sdm/libs/hwc2/hwc_display.h b/sdm/libs/hwc2/hwc_display.h
index 86a88d3..80dd963 100644
--- a/sdm/libs/hwc2/hwc_display.h
+++ b/sdm/libs/hwc2/hwc_display.h
@@ -434,6 +434,7 @@
bool CanSkipSdmPrepare(uint32_t *num_types, uint32_t *num_requests);
void UpdateRefreshRate();
void WaitOnPreviousFence();
+ void UpdateActiveConfig();
qService::QService *qservice_ = NULL;
DisplayClass display_class_;
uint32_t geometry_changes_ = GeometryChanges::kNone;
@@ -445,6 +446,8 @@
bool first_cycle_ = true; // false if a display commit has succeeded on the device.
int fbt_release_fence_ = -1;
int release_fence_ = -1;
+ bool pending_config_ = false;
+ hwc2_config_t pending_config_index_ = 0;
};
inline int HWCDisplay::Perform(uint32_t operation, ...) {