diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-10-29 19:14:35 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-10-29 19:14:35 -0700 |
commit | efd6a3531638a2ed1b0de49b7f5b2a7f8035b3f5 (patch) | |
tree | 2258f780f838842599f37a07175bef854ae1d9f6 | |
parent | a0394ad853c9d6d17f6386c6bfe43a2dcd7ae76f (diff) | |
parent | 67c1f901caa0bf3076a46bf9b3c6f1b03b4ae050 (diff) | |
download | display-efd6a3531638a2ed1b0de49b7f5b2a7f8035b3f5.tar.gz |
Merge "sdm: Allow draw cycle in doze state." into dev-1.0
-rw-r--r-- | sdm/include/core/sdm_types.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/display_base.cpp | 97 | ||||
-rw-r--r-- | sdm/libs/core/display_base.h | 1 | ||||
-rw-r--r-- | sdm/libs/core/display_primary.cpp | 4 | ||||
-rw-r--r-- | sdm/libs/core/fb/hw_virtual.cpp | 4 | ||||
-rw-r--r-- | sdm/libs/core/fb/hw_virtual.h | 1 | ||||
-rw-r--r-- | sdm/libs/hwc/hwc_display.cpp | 40 | ||||
-rw-r--r-- | sdm/libs/hwc/hwc_display.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | sdm/libs/hwc/hwc_display_external.cpp | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | sdm/libs/hwc/hwc_display_primary.cpp | 6 |
10 files changed, 85 insertions, 76 deletions
diff --git a/sdm/include/core/sdm_types.h b/sdm/include/core/sdm_types.h index 44985a98..af7a20b3 100644 --- a/sdm/include/core/sdm_types.h +++ b/sdm/include/core/sdm_types.h @@ -41,6 +41,7 @@ enum DisplayError { kErrorNone, //!< Call executed successfully. kErrorUndefined, //!< An unspecified error has occured. kErrorNotSupported, //!< Requested operation is not supported. + kErrorPermission, //!< Operation is not permitted in current state. kErrorVersion, //!< Client is using advanced version of interfaces and calling into an //!< older version of display library. kErrorDataAlignment, //!< Client data structures are not aligned on naturual boundaries. diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp index 61079178..96e3fbff 100644 --- a/sdm/libs/core/display_base.cpp +++ b/sdm/libs/core/display_base.cpp @@ -175,57 +175,58 @@ DisplayError DisplayBase::Prepare(LayerStack *layer_stack) { return error; } - if (state_ == kStateOn) { - if (color_mgr_) { - disable_partial_update = color_mgr_->NeedsPartialUpdateDisable(); - if (disable_partial_update) { - ControlPartialUpdate(false, &pending); - } + if (!active_) { + return kErrorPermission; + } + + if (color_mgr_) { + disable_partial_update = color_mgr_->NeedsPartialUpdateDisable(); + if (disable_partial_update) { + ControlPartialUpdate(false, &pending); } + } - // Clean hw layers for reuse. - hw_layers_.info = HWLayersInfo(); - hw_layers_.info.stack = layer_stack; - hw_layers_.output_compression = 1.0f; + // Clean hw layers for reuse. + hw_layers_.info = HWLayersInfo(); + hw_layers_.info.stack = layer_stack; + hw_layers_.output_compression = 1.0f; - comp_manager_->PrePrepare(display_comp_ctx_, &hw_layers_); - while (true) { - error = comp_manager_->Prepare(display_comp_ctx_, &hw_layers_); - if (error != kErrorNone) { - break; - } + comp_manager_->PrePrepare(display_comp_ctx_, &hw_layers_); + while (true) { + error = comp_manager_->Prepare(display_comp_ctx_, &hw_layers_); + if (error != kErrorNone) { + break; + } - if (IsRotationRequired(&hw_layers_)) { - if (!rotator_intf_) { - continue; - } - error = rotator_intf_->Prepare(display_rotator_ctx_, &hw_layers_); - } else { - // Release all the previous rotator sessions. - if (rotator_intf_) { - error = rotator_intf_->Purge(display_rotator_ctx_); - } + if (IsRotationRequired(&hw_layers_)) { + if (!rotator_intf_) { + continue; } + error = rotator_intf_->Prepare(display_rotator_ctx_, &hw_layers_); + } else { + // Release all the previous rotator sessions. + if (rotator_intf_) { + error = rotator_intf_->Purge(display_rotator_ctx_); + } + } + if (error == kErrorNone) { + error = hw_intf_->Validate(&hw_layers_); if (error == kErrorNone) { - error = hw_intf_->Validate(&hw_layers_); - if (error == kErrorNone) { - // Strategy is successful now, wait for Commit(). - pending_commit_ = true; - break; - } - if (error == kErrorShutDown) { - comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_); - return error; - } + // Strategy is successful now, wait for Commit(). + pending_commit_ = true; + break; + } + if (error == kErrorShutDown) { + comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_); + return error; } } - comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_); - if (disable_partial_update) { - ControlPartialUpdate(true, &pending); - } - } else { - return kErrorNotSupported; + } + + comp_manager_->PostPrepare(display_comp_ctx_, &hw_layers_); + if (disable_partial_update) { + ControlPartialUpdate(true, &pending); } return error; @@ -238,8 +239,8 @@ DisplayError DisplayBase::Commit(LayerStack *layer_stack) { return kErrorParameters; } - if (state_ != kStateOn) { - return kErrorNotSupported; + if (!active_) { + return kErrorPermission; } if (!pending_commit_) { @@ -300,8 +301,8 @@ DisplayError DisplayBase::Commit(LayerStack *layer_stack) { DisplayError DisplayBase::Flush() { DisplayError error = kErrorNone; - if (state_ != kStateOn) { - return kErrorNone; + if (!active_) { + return kErrorPermission; } hw_layers_.info.count = 0; @@ -369,6 +370,7 @@ bool DisplayBase::IsUnderscanSupported() { DisplayError DisplayBase::SetDisplayState(DisplayState state) { DisplayError error = kErrorNone; + bool active = false; DLOGI("Set state = %d, display %d", state, display_type_); @@ -399,10 +401,12 @@ DisplayError DisplayBase::SetDisplayState(DisplayState state) { case kStateOn: error = hw_intf_->PowerOn(); + active = true; break; case kStateDoze: error = hw_intf_->Doze(); + active = true; break; case kStateDozeSuspend: @@ -419,6 +423,7 @@ DisplayError DisplayBase::SetDisplayState(DisplayState state) { } if (error == kErrorNone) { + active_ = active; state_ = state; } diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h index 74d07d38..436af4fd 100644 --- a/sdm/libs/core/display_base.h +++ b/sdm/libs/core/display_base.h @@ -92,6 +92,7 @@ class DisplayBase : public DisplayInterface { CompManager *comp_manager_ = NULL; RotatorInterface *rotator_intf_ = NULL; DisplayState state_ = kStateOff; + bool active_ = false; Handle hw_device_ = 0; Handle display_comp_ctx_ = 0; Handle display_rotator_ctx_ = 0; diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp index 63fe6b24..4936b9bb 100644 --- a/sdm/libs/core/display_primary.cpp +++ b/sdm/libs/core/display_primary.cpp @@ -208,7 +208,7 @@ DisplayError DisplayPrimary::SetDisplayMode(uint32_t mode) { DisplayError error = kErrorNone; HWDisplayMode hw_display_mode = kModeDefault; - if (state_ != kStateOn) { + if (!active_) { DLOGW("Invalid display state = %d. Panel must be on.", state_); return kErrorNotSupported; } @@ -283,7 +283,7 @@ DisplayError DisplayPrimary::GetRefreshRateRange(uint32_t *min_refresh_rate, DisplayError DisplayPrimary::SetRefreshRate(uint32_t refresh_rate) { SCOPE_LOCK(locker_); - if (state_ != kStateOn || !hw_panel_info_.dynamic_fps) { + if (!active_ || !hw_panel_info_.dynamic_fps) { return kErrorNotSupported; } diff --git a/sdm/libs/core/fb/hw_virtual.cpp b/sdm/libs/core/fb/hw_virtual.cpp index 033159f4..27c979ae 100644 --- a/sdm/libs/core/fb/hw_virtual.cpp +++ b/sdm/libs/core/fb/hw_virtual.cpp @@ -74,5 +74,9 @@ DisplayError HWVirtual::Validate(HWLayers *hw_layers) { return HWDevice::Validate(hw_layers); } +DisplayError HWVirtual::Flush() { + return kErrorNone; +} + } // namespace sdm diff --git a/sdm/libs/core/fb/hw_virtual.h b/sdm/libs/core/fb/hw_virtual.h index 2b740d56..c0591b31 100644 --- a/sdm/libs/core/fb/hw_virtual.h +++ b/sdm/libs/core/fb/hw_virtual.h @@ -39,6 +39,7 @@ class HWVirtual : public HWDevice { HWVirtual(BufferSyncHandler *buffer_sync_handler, HWInfoInterface *hw_info_intf); virtual DisplayError Init(HWEventHandler *eventhandler); virtual DisplayError Validate(HWLayers *hw_layers); + virtual DisplayError Flush(); }; } // namespace sdm diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp index 1372ee6a..50aae41c 100644 --- a/sdm/libs/hwc/hwc_display.cpp +++ b/sdm/libs/hwc/hwc_display.cpp @@ -163,6 +163,7 @@ int HWCDisplay::EventControl(int event, int enable) { int HWCDisplay::SetPowerMode(int mode) { DLOGI("display = %d, mode = %d", id_, mode); DisplayState state = kStateOff; + bool flush_on_error = flush_on_error_; if (shutdown_pending_) { return 0; @@ -170,26 +171,35 @@ int HWCDisplay::SetPowerMode(int mode) { switch (mode) { case HWC_POWER_MODE_OFF: + // During power off, all of the buffers are released. + // Do not flush until a buffer is successfully submitted again. + flush_on_error = false; state = kStateOff; break; + case HWC_POWER_MODE_NORMAL: state = kStateOn; last_power_mode_ = HWC_POWER_MODE_NORMAL; break; + case HWC_POWER_MODE_DOZE: state = kStateDoze; last_power_mode_ = HWC_POWER_MODE_DOZE; break; + case HWC_POWER_MODE_DOZE_SUSPEND: state = kStateDozeSuspend; last_power_mode_ = HWC_POWER_MODE_DOZE_SUSPEND; break; + default: return -EINVAL; } DisplayError error = display_intf_->SetDisplayState(state); - if (error != kErrorNone) { + if (error == kErrorNone) { + flush_on_error_ = flush_on_error; + } else { if (error == kErrorShutDown) { shutdown_pending_ = true; return 0; @@ -593,6 +603,7 @@ int HWCDisplay::PrepareLayerStack(hwc_display_contents_1_t *content_list) { if (shutdown_pending_) { return 0; } + size_t num_hw_layers = content_list->numHwLayers; if (!skip_prepare_) { @@ -600,12 +611,12 @@ int HWCDisplay::PrepareLayerStack(hwc_display_contents_1_t *content_list) { if (error != kErrorNone) { if (error == kErrorShutDown) { shutdown_pending_ = true; - return 0; + } else if (error != kErrorPermission) { + DLOGE("Prepare failed. Error = %d", error); + // To prevent surfaceflinger infinite wait, flush the previous frame during Commit() + // so that previous buffer and fences are released, and override the error. + flush_ = true; } - DLOGE("Prepare failed. Error = %d", error); - // To prevent surfaceflinger infinite wait, flush the previous frame during Commit() so that - // previous buffer and fences are released, and override the error. - flush_ = true; return 0; } @@ -685,17 +696,18 @@ int HWCDisplay::CommitLayerStack(hwc_display_contents_1_t *content_list) { } if (error == kErrorNone) { - // Do no call flush on errors, if a successful buffer is never submitted. + // A commit is successfully submitted, start flushing on failure now onwards. flush_on_error_ = true; } else { if (error == kErrorShutDown) { shutdown_pending_ = true; return status; + } else if (error != kErrorPermission) { + DLOGE("Commit failed. Error = %d", error); + // To prevent surfaceflinger infinite wait, flush the previous frame during Commit() + // so that previous buffer and fences are released, and override the error. + flush_ = true; } - DLOGE("Commit failed. Error = %d", error); - // To prevent surfaceflinger infinite wait, flush the previous frame during Commit() so that - // previous buffer and fences are released, and override the error. - flush_ = true; } } @@ -706,11 +718,9 @@ int HWCDisplay::PostCommitLayerStack(hwc_display_contents_1_t *content_list) { size_t num_hw_layers = content_list->numHwLayers; int status = 0; + // Do no call flush on errors, if a successful buffer is never submitted. if (flush_ && flush_on_error_) { - DisplayError error = display_intf_->Flush(); - if (error != kErrorNone) { - DLOGE("Flush failed. Error = %d", error); - } + display_intf_->Flush(); } // Set the release fence fd to the blit engine diff --git a/sdm/libs/hwc/hwc_display.h b/sdm/libs/hwc/hwc_display.h index 234477c1..04d88490 100644 --- a/sdm/libs/hwc/hwc_display.h +++ b/sdm/libs/hwc/hwc_display.h @@ -187,7 +187,6 @@ class HWCDisplay : public DisplayEventHandler { bool use_blit_comp_ = false; bool secure_display_active_ = false; bool skip_prepare_ = false; - bool solid_fill_enable_ = false; uint32_t solid_fill_color_ = 0; LayerRect display_rect_; diff --git a/sdm/libs/hwc/hwc_display_external.cpp b/sdm/libs/hwc/hwc_display_external.cpp index 99c903c8..28582f12 100644..100755 --- a/sdm/libs/hwc/hwc_display_external.cpp +++ b/sdm/libs/hwc/hwc_display_external.cpp @@ -92,12 +92,6 @@ int HWCDisplayExternal::Prepare(hwc_display_contents_1_t *content_list) { return status; } - size_t num_hw_layers = content_list->numHwLayers; - if (num_hw_layers <= 1) { - flush_ = true; - return 0; - } - status = PrePrepareLayerStack(content_list); if (status) { return status; diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp index 416e3907..fb134a97 100644..100755 --- a/sdm/libs/hwc/hwc_display_primary.cpp +++ b/sdm/libs/hwc/hwc_display_primary.cpp @@ -127,12 +127,6 @@ int HWCDisplayPrimary::Prepare(hwc_display_contents_1_t *content_list) { return status; } - size_t num_hw_layers = content_list->numHwLayers; - if (num_hw_layers <= 1) { - flush_ = true; - return 0; - } - status = PrePrepareLayerStack(content_list); if (status) { return status; |