diff options
author | Chirag Khurana <ckhurana@codeaurora.org> | 2021-08-02 13:53:21 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2021-09-21 22:07:47 -0700 |
commit | ea0673c10796b2f8fb832907601a7e950622350a (patch) | |
tree | 2599600f3ee8936edd4e0c203fea9293089e2331 | |
parent | a917b9c6dd84d71ff0385e416b910978fc17e454 (diff) |
composer: add TWM display state transition support
Add additional parameter to trigger display state
transition to DOZE state if display is in ON state.
Change-Id: Iacbb5c21cb5ddec985668f0a0608c1555ba08d09
-rw-r--r-- | composer/hwc_display.h | 2 | ||||
-rw-r--r-- | composer/hwc_display_builtin.cpp | 26 | ||||
-rw-r--r-- | composer/hwc_display_builtin.h | 2 | ||||
-rw-r--r-- | composer/hwc_session.cpp | 7 | ||||
-rw-r--r-- | libqdutils/display_config.cpp | 3 | ||||
-rw-r--r-- | libqdutils/display_config.h | 12 |
6 files changed, 45 insertions, 7 deletions
diff --git a/composer/hwc_display.h b/composer/hwc_display.h index c76bcdc0..e42443c8 100644 --- a/composer/hwc_display.h +++ b/composer/hwc_display.h @@ -250,7 +250,7 @@ class HWCDisplay : public DisplayEventHandler { virtual int SetState(bool connected) { return kErrorNotSupported; } - virtual DisplayError SetStandByMode(bool enable) { + virtual DisplayError SetStandByMode(bool enable, bool is_twm) { return kErrorNotSupported; } virtual DisplayError Flush() { diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp index 7d1cdf94..86a149ba 100644 --- a/composer/hwc_display_builtin.cpp +++ b/composer/hwc_display_builtin.cpp @@ -1331,11 +1331,31 @@ DisplayError HWCDisplayBuiltIn::GetSupportedDSIClock(std::vector<uint64_t> *bitc return kErrorNotSupported; } -DisplayError HWCDisplayBuiltIn::SetStandByMode(bool enable) { +DisplayError HWCDisplayBuiltIn::SetStandByMode(bool enable, bool is_twm) { if (enable) { if (!display_null_.IsActive()) { stored_display_intf_ = display_intf_; display_intf_ = &display_null_; + shared_ptr<Fence> release_fence = nullptr; + + if (is_twm && current_power_mode_ == HWC2::PowerMode::On) { + DLOGD("Display is in ON state and device is entering TWM mode."); + DisplayError error = stored_display_intf_->SetDisplayState(kStateDoze, + false /* teardown */, + &release_fence); + if (error != kErrorNone) { + if (error == kErrorShutDown) { + shutdown_pending_ = true; + return error; + } + DLOGE("Set state failed. Error = %d", error); + return error; + } else { + current_power_mode_ = HWC2::PowerMode::Doze; + DLOGD("Display moved to DOZE state."); + } + } + display_null_.SetActive(true); DLOGD("Null display is connected successfully"); } else { @@ -1343,6 +1363,10 @@ DisplayError HWCDisplayBuiltIn::SetStandByMode(bool enable) { } } else { if (display_null_.IsActive()) { + if (is_twm) { + DLOGE("Unexpected event. Display state may be inconsistent."); + return kErrorNotSupported; + } display_intf_ = stored_display_intf_; validated_ = false; display_null_.SetActive(false); diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h index ab973bc1..e1a2d25d 100644 --- a/composer/hwc_display_builtin.h +++ b/composer/hwc_display_builtin.h @@ -114,7 +114,7 @@ class HWCDisplayBuiltIn : public HWCDisplay, public SyncTask<LayerStitchTaskCode virtual DisplayError SetDynamicDSIClock(uint64_t bitclk); virtual DisplayError GetDynamicDSIClock(uint64_t *bitclk); virtual DisplayError GetSupportedDSIClock(std::vector<uint64_t> *bitclk_rates); - virtual DisplayError SetStandByMode(bool enable); + virtual DisplayError SetStandByMode(bool enable, bool is_twm); virtual HWC2::Error UpdateDisplayId(hwc2_display_t id); virtual HWC2::Error SetPendingRefresh(); virtual HWC2::Error SetPanelBrightness(float brightness); diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp index 51d25f28..f12263ba 100644 --- a/composer/hwc_session.cpp +++ b/composer/hwc_session.cpp @@ -2553,13 +2553,18 @@ android::status_t HWCSession::SetStandByMode(const android::Parcel *input_parcel SCOPE_LOCK(locker_[HWC_DISPLAY_PRIMARY]); bool enable = (input_parcel->readInt32() > 0); + bool is_twm = (input_parcel->readInt32() > 0); if (!hwc_display_[HWC_DISPLAY_PRIMARY]) { DLOGI("Primary display is not initialized"); return -EINVAL; } - hwc_display_[HWC_DISPLAY_PRIMARY]->SetStandByMode(enable); + DisplayError error = hwc_display_[HWC_DISPLAY_PRIMARY]->SetStandByMode(enable, is_twm); + if (error != kErrorNone) { + DLOGE("SetStandByMode failed. Error = %d", error); + return -EINVAL; + } return android::NO_ERROR; } diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp index dc590e95..0697c88c 100644 --- a/libqdutils/display_config.cpp +++ b/libqdutils/display_config.cpp @@ -394,13 +394,14 @@ extern "C" int waitForComposerInit() { return !status; } -extern "C" int setStandByMode(int mode) { +extern "C" int setStandByMode(int mode, int is_twm = false) { status_t err = (status_t) FAILED_TRANSACTION; sp<IQService> binder = getBinder(); Parcel inParcel, outParcel; if(binder != NULL) { inParcel.writeInt32(mode); + inParcel.writeInt32(is_twm); err = binder->dispatch(IQService::SET_STAND_BY_MODE, &inParcel, &outParcel); if(err) { diff --git a/libqdutils/display_config.h b/libqdutils/display_config.h index d3f75d56..66f6a3f6 100644 --- a/libqdutils/display_config.h +++ b/libqdutils/display_config.h @@ -170,8 +170,16 @@ int getSupportedBitClk(int dpy, std::vector<uint64_t>& bit_rates); // Sets the specified min and max luminance values. int setPanelLuminanceAttributes(int dpy, float min_lum, float max_lum); -// Sets display standy mode -extern "C" int setStandByMode(int mode); +// Informs HWC about TWM entry/exit based on which NULL Display is connected +// or disconnected. +// mode -> 0 for exit sequence, 1 for entry sequence. +// is_twm -> +// 0 for regular ambient mode +// 1 for TWM with framework shutdown mode (If display is in ON state, then +// this would put display in DOZE state). +// Using 0 for mode value and 1 for is_twm is not valid, it may lead to +// state inconsistency between Android Framework and HAL. +int setStandByMode(int mode, int is_twm); // Get Panel Resolution extern "C" int getPanelResolution(int *width, int *height); |