Merge "sdm: Allow draw cycle in doze state." into dev-1.0
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
commit
efd6a35316
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
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_);
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if (error == kErrorNone) {
|
||||
error = hw_intf_->Validate(&hw_layers_);
|
||||
if (error == kErrorNone) {
|
||||
// Strategy is successful now, wait for Commit().
|
||||
pending_commit_ = true;
|
||||
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 (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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,5 +74,9 @@ DisplayError HWVirtual::Validate(HWLayers *hw_layers) {
|
||||
return HWDevice::Validate(hw_layers);
|
||||
}
|
||||
|
||||
DisplayError HWVirtual::Flush() {
|
||||
return kErrorNone;
|
||||
}
|
||||
|
||||
} // namespace sdm
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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_;
|
||||
|
||||
6
sdm/libs/hwc/hwc_display_external.cpp
Normal file → Executable file
6
sdm/libs/hwc/hwc_display_external.cpp
Normal file → Executable file
@@ -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;
|
||||
|
||||
6
sdm/libs/hwc/hwc_display_primary.cpp
Normal file → Executable file
6
sdm/libs/hwc/hwc_display_primary.cpp
Normal file → Executable file
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user