drm_hwcomposer: Deprecate usage of HWC2 GetActiveConfig
Add HwcDisplay::GetLastRequestedConfig, and use this to implement
support for getActiveConfig.
Change-Id: I089e2ac0046eceb5da9c130537105290a973ae4a
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 0ab43f9..ec481e1 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -104,6 +104,14 @@
return &config_iter->second;
}
+const HwcDisplayConfig *HwcDisplay::GetLastRequestedConfig() const {
+ auto config_iter = configs_.hwc_configs.find(staged_mode_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 7cdc0b8..a315540 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -62,6 +62,11 @@
// Get the config representing the mode that has been committed to KMS.
const HwcDisplayConfig *GetCurrentConfig() const;
+ // Get the config that was last requested through SetActiveConfig and similar
+ // functions. This may differ from the GetCurrentConfig if the config change
+ // is queued up to take effect in the future.
+ const HwcDisplayConfig *GetLastRequestedConfig() 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 7e9b88b..e2d5b21 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -646,7 +646,7 @@
}
ndk::ScopedAStatus ComposerClient::getActiveConfig(int64_t display_id,
- int32_t* config) {
+ int32_t* config_id) {
DEBUG_FUNC();
const std::unique_lock lock(hwc_->GetResMan().GetMainLock());
HwcDisplay* display = GetDisplay(display_id);
@@ -654,13 +654,12 @@
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
- uint32_t hwc2_config = 0;
- const hwc3::Error error = Hwc2toHwc3Error(
- display->GetActiveConfig(&hwc2_config));
- if (error != hwc3::Error::kNone) {
- return ToBinderStatus(error);
+ const HwcDisplayConfig* config = display->GetLastRequestedConfig();
+ if (config == nullptr) {
+ return ToBinderStatus(hwc3::Error::kBadConfig);
}
- *config = Hwc2ConfigIdToHwc3(hwc2_config);
+
+ *config_id = Hwc2ConfigIdToHwc3(config->id);
return ndk::ScopedAStatus::ok();
}