Merge "sdm: Change idle fallback time dynamically."

This commit is contained in:
Linux Build Service Account
2017-03-12 23:23:25 -07:00
committed by Gerrit - the friendly Code Review server
13 changed files with 90 additions and 79 deletions

View File

@@ -405,11 +405,11 @@ class DisplayInterface {
/*! @brief Method to set idle timeout value. Idle fallback is disabled with timeout value 0. /*! @brief Method to set idle timeout value. Idle fallback is disabled with timeout value 0.
@param[in] timeout value in milliseconds. @param[in] active_ms value in milliseconds.
@return \link void \endlink @return \link void \endlink
*/ */
virtual void SetIdleTimeoutMs(uint32_t timeout_ms) = 0; virtual void SetIdleTimeoutMs(uint32_t active_ms) = 0;
/*! @brief Method to set maximum number of mixer stages for each display. /*! @brief Method to set maximum number of mixer stages for each display.

View File

@@ -469,7 +469,9 @@ struct HWLayersInfo {
// be programmed on hardware. // be programmed on hardware.
uint32_t roi_index[kMaxSDELayers] = {0}; // Stores the ROI index where the layers are visible. uint32_t roi_index[kMaxSDELayers] = {0}; // Stores the ROI index where the layers are visible.
int sync_handle = -1; int sync_handle = -1; // Release fence id for current draw cycle.
int set_idle_time_ms = -1; // Set idle time to the new specified value.
// -1 indicates no change in idle time since last set value.
std::vector<LayerRect> left_frame_roi = {}; // Left ROI. std::vector<LayerRect> left_frame_roi = {}; // Left ROI.
std::vector<LayerRect> right_frame_roi = {}; // Right ROI. std::vector<LayerRect> right_frame_roi = {}; // Right ROI.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. * Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted * Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@@ -54,6 +54,7 @@ class StrategyInterface {
const DisplayConfigVariableInfo &fb_config) = 0; const DisplayConfigVariableInfo &fb_config) = 0;
virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0; virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
virtual DisplayError Purge() = 0; virtual DisplayError Purge() = 0;
virtual DisplayError SetIdleTimeoutMs(uint32_t active_ms) = 0;
protected: protected:
virtual ~StrategyInterface() { } virtual ~StrategyInterface() { }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. * Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted * Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@@ -48,6 +48,8 @@
#define ROUND_UP_ALIGN_UP(value, a) FLOAT(CeilToMultipleOf(UINT32(value + 0.5f), UINT32(a))) #define ROUND_UP_ALIGN_UP(value, a) FLOAT(CeilToMultipleOf(UINT32(value + 0.5f), UINT32(a)))
#define IDLE_TIMEOUT_DEFAULT_MS 70 #define IDLE_TIMEOUT_DEFAULT_MS 70
#define IDLE_TIMEOUT_ACTIVE_MS IDLE_TIMEOUT_DEFAULT_MS
#define IDLE_TIMEOUT_INACTIVE_MS 520
#define IS_RGB_FORMAT(format) (((format) < kFormatYCbCr420Planar) ? true: false) #define IS_RGB_FORMAT(format) (((format) < kFormatYCbCr420Planar) ? true: false)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. * Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@@ -64,7 +64,7 @@ class Debug {
static inline DebugHandler* Get() { return debug_.debug_handler_; } static inline DebugHandler* Get() { return debug_.debug_handler_; }
static int GetSimulationFlag(); static int GetSimulationFlag();
static int GetHDMIResolution(); static int GetHDMIResolution();
static uint32_t GetIdleTimeoutMs(); static void GetIdleTimeoutMs(uint32_t *active_ms, uint32_t *inactive_ms);
static int GetBootAnimLayerCount(); static int GetBootAnimLayerCount();
static bool IsRotatorDownScaleDisabled(); static bool IsRotatorDownScaleDisabled();
static bool IsDecimationDisabled(); static bool IsDecimationDisabled();

View File

@@ -397,6 +397,15 @@ void CompManager::Purge(Handle display_ctx) {
display_comp_ctx->strategy->Purge(); display_comp_ctx->strategy->Purge();
} }
DisplayError CompManager::SetIdleTimeoutMs(Handle display_ctx, uint32_t active_ms) {
SCOPE_LOCK(locker_);
DisplayCompositionContext *display_comp_ctx =
reinterpret_cast<DisplayCompositionContext *>(display_ctx);
return display_comp_ctx->strategy->SetIdleTimeoutMs(active_ms);
}
void CompManager::ProcessIdleTimeout(Handle display_ctx) { void CompManager::ProcessIdleTimeout(Handle display_ctx) {
SCOPE_LOCK(locker_); SCOPE_LOCK(locker_);
@@ -518,21 +527,6 @@ DisplayError CompManager::SetMaxBandwidthMode(HWBwModes mode) {
return resource_intf_->SetMaxBandwidthMode(mode); return resource_intf_->SetMaxBandwidthMode(mode);
} }
bool CompManager::CanSetIdleTimeout(Handle display_ctx) {
DisplayCompositionContext *display_comp_ctx =
reinterpret_cast<DisplayCompositionContext *>(display_ctx);
if (!display_comp_ctx) {
return false;
}
if (!display_comp_ctx->idle_fallback) {
return true;
}
return false;
}
DisplayError CompManager::GetScaleLutConfig(HWScaleLutInfo *lut_info) { DisplayError CompManager::GetScaleLutConfig(HWScaleLutInfo *lut_info) {
return resource_intf_->GetScaleLutConfig(lut_info); return resource_intf_->GetScaleLutConfig(lut_info);
} }

View File

@@ -59,6 +59,7 @@ class CompManager : public DumpImpl {
DisplayError ReConfigure(Handle display_ctx, HWLayers *hw_layers); DisplayError ReConfigure(Handle display_ctx, HWLayers *hw_layers);
DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers); DisplayError PostCommit(Handle display_ctx, HWLayers *hw_layers);
void Purge(Handle display_ctx); void Purge(Handle display_ctx);
DisplayError SetIdleTimeoutMs(Handle display_ctx, uint32_t active_ms);
void ProcessIdleTimeout(Handle display_ctx); void ProcessIdleTimeout(Handle display_ctx);
void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level); void ProcessThermalEvent(Handle display_ctx, int64_t thermal_level);
void ProcessIdlePowerCollapse(Handle display_ctx); void ProcessIdlePowerCollapse(Handle display_ctx);
@@ -67,7 +68,6 @@ class CompManager : public DumpImpl {
DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90); DisplayError ValidateScaling(const LayerRect &crop, const LayerRect &dst, bool rotate90);
DisplayError ValidateCursorPosition(Handle display_ctx, HWLayers *hw_layers, int x, int y); DisplayError ValidateCursorPosition(Handle display_ctx, HWLayers *hw_layers, int x, int y);
bool SupportLayerAsCursor(Handle display_ctx, HWLayers *hw_layers); bool SupportLayerAsCursor(Handle display_ctx, HWLayers *hw_layers);
bool CanSetIdleTimeout(Handle display_ctx);
bool SetDisplayState(Handle display_ctx, DisplayState state, DisplayType display_type); bool SetDisplayState(Handle display_ctx, DisplayState state, DisplayType display_type);
DisplayError SetMaxBandwidthMode(HWBwModes mode); DisplayError SetMaxBandwidthMode(HWBwModes mode);
DisplayError GetScaleLutConfig(HWScaleLutInfo *lut_info); DisplayError GetScaleLutConfig(HWScaleLutInfo *lut_info);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted * Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@@ -99,7 +99,7 @@ class DisplayBase : public DisplayInterface, DumpImpl {
return kErrorNotSupported; return kErrorNotSupported;
} }
virtual DisplayError SetVSyncState(bool enable); virtual DisplayError SetVSyncState(bool enable);
virtual void SetIdleTimeoutMs(uint32_t timeout_ms) {} virtual void SetIdleTimeoutMs(uint32_t active_ms) {}
virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height); virtual DisplayError SetMixerResolution(uint32_t width, uint32_t height);
virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); virtual DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info); virtual DisplayError SetFrameBufferConfig(const DisplayConfigVariableInfo &variable_info);

View File

@@ -59,8 +59,6 @@ DisplayError DisplayPrimary::Init() {
return error; return error;
} }
idle_timeout_ms_ = Debug::GetIdleTimeoutMs();
if (hw_panel_info_.mode == kModeCommand && Debug::IsVideoModeEnabled()) { if (hw_panel_info_.mode == kModeCommand && Debug::IsVideoModeEnabled()) {
error = hw_intf_->SetDisplayMode(kModeVideo); error = hw_intf_->SetDisplayMode(kModeVideo);
if (error != kErrorNone) { if (error != kErrorNone) {
@@ -145,8 +143,6 @@ DisplayError DisplayPrimary::Commit(LayerStack *layer_stack) {
} }
} }
bool set_idle_timeout = comp_manager_->CanSetIdleTimeout(display_comp_ctx_);
error = DisplayBase::Commit(layer_stack); error = DisplayBase::Commit(layer_stack);
if (error != kErrorNone) { if (error != kErrorNone) {
return error; return error;
@@ -154,13 +150,12 @@ DisplayError DisplayPrimary::Commit(LayerStack *layer_stack) {
DisplayBase::ReconfigureDisplay(); DisplayBase::ReconfigureDisplay();
if (hw_panel_info_.mode == kModeVideo) { int idle_time_ms = hw_layers_.info.set_idle_time_ms;
if (set_idle_timeout && !layer_stack->flags.single_buffered_layer_present) { if (idle_time_ms >= 0) {
hw_intf_->SetIdleTimeoutMs(idle_timeout_ms_); hw_intf_->SetIdleTimeoutMs(UINT32(idle_time_ms));
} else { }
hw_intf_->SetIdleTimeoutMs(0);
} if (switch_to_cmd_) {
} else if (switch_to_cmd_) {
uint32_t pending; uint32_t pending;
switch_to_cmd_ = false; switch_to_cmd_ = false;
ControlPartialUpdate(true /* enable */, &pending); ControlPartialUpdate(true /* enable */, &pending);
@@ -185,52 +180,58 @@ DisplayError DisplayPrimary::SetDisplayState(DisplayState state) {
return kErrorNone; return kErrorNone;
} }
void DisplayPrimary::SetIdleTimeoutMs(uint32_t timeout_ms) { void DisplayPrimary::SetIdleTimeoutMs(uint32_t active_ms) {
lock_guard<recursive_mutex> obj(recursive_mutex_); lock_guard<recursive_mutex> obj(recursive_mutex_);
// Idle fallback feature is supported only for video mode panel. if (comp_manager_->SetIdleTimeoutMs(display_comp_ctx_, active_ms) == kErrorNone) {
if (hw_panel_info_.mode == kModeVideo) { hw_intf_->SetIdleTimeoutMs(active_ms);
hw_intf_->SetIdleTimeoutMs(timeout_ms);
} }
idle_timeout_ms_ = timeout_ms;
} }
DisplayError DisplayPrimary::SetDisplayMode(uint32_t mode) { DisplayError DisplayPrimary::SetDisplayMode(uint32_t mode) {
lock_guard<recursive_mutex> obj(recursive_mutex_);
DisplayError error = kErrorNone; DisplayError error = kErrorNone;
HWDisplayMode hw_display_mode = static_cast<HWDisplayMode>(mode);
uint32_t pending = 0;
if (!active_) { // Limit scope of mutex to this block
DLOGW("Invalid display state = %d. Panel must be on.", state_); {
return kErrorNotSupported; lock_guard<recursive_mutex> obj(recursive_mutex_);
HWDisplayMode hw_display_mode = static_cast<HWDisplayMode>(mode);
uint32_t pending = 0;
if (!active_) {
DLOGW("Invalid display state = %d. Panel must be on.", state_);
return kErrorNotSupported;
}
if (hw_display_mode != kModeCommand && hw_display_mode != kModeVideo) {
DLOGW("Invalid panel mode parameters. Requested = %d", hw_display_mode);
return kErrorParameters;
}
if (hw_display_mode == hw_panel_info_.mode) {
DLOGW("Same display mode requested. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return kErrorNone;
}
error = hw_intf_->SetDisplayMode(hw_display_mode);
if (error != kErrorNone) {
DLOGW("Retaining current display mode. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return error;
}
if (mode == kModeVideo) {
ControlPartialUpdate(false /* enable */, &pending);
} else if (mode == kModeCommand) {
// Flush idle timeout value currently set.
hw_intf_->SetIdleTimeoutMs(0);
switch_to_cmd_ = true;
}
} }
if (hw_display_mode != kModeCommand && hw_display_mode != kModeVideo) { // Request for a new draw cycle. New display mode will get applied on next draw cycle.
DLOGW("Invalid panel mode parameters. Requested = %d", hw_display_mode); // New idle time will get configured as part of this.
return kErrorParameters; event_handler_->Refresh();
}
if (hw_display_mode == hw_panel_info_.mode) {
DLOGW("Same display mode requested. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return kErrorNone;
}
error = hw_intf_->SetDisplayMode(hw_display_mode);
if (error != kErrorNone) {
DLOGW("Retaining current display mode. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return error;
}
if (mode == kModeVideo) {
ControlPartialUpdate(false /* enable */, &pending);
hw_intf_->SetIdleTimeoutMs(idle_timeout_ms_);
} else if (mode == kModeCommand) {
switch_to_cmd_ = true;
hw_intf_->SetIdleTimeoutMs(0);
}
return error; return error;
} }

View File

@@ -45,7 +45,7 @@ class DisplayPrimary : public DisplayBase, HWEventHandler {
virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending); virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending);
virtual DisplayError DisablePartialUpdateOneFrame(); virtual DisplayError DisablePartialUpdateOneFrame();
virtual DisplayError SetDisplayState(DisplayState state); virtual DisplayError SetDisplayState(DisplayState state);
virtual void SetIdleTimeoutMs(uint32_t timeout_ms); virtual void SetIdleTimeoutMs(uint32_t active_ms);
virtual DisplayError SetDisplayMode(uint32_t mode); virtual DisplayError SetDisplayMode(uint32_t mode);
virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate); virtual DisplayError GetRefreshRateRange(uint32_t *min_refresh_rate, uint32_t *max_refresh_rate);
virtual DisplayError SetRefreshRate(uint32_t refresh_rate); virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
@@ -63,7 +63,6 @@ class DisplayPrimary : public DisplayBase, HWEventHandler {
private: private:
bool NeedsAVREnable(); bool NeedsAVREnable();
uint32_t idle_timeout_ms_ = 0;
std::vector<HWEvent> event_list_ = { HWEvent::VSYNC, HWEvent::EXIT, HWEvent::IDLE_NOTIFY, std::vector<HWEvent> event_list_ = { HWEvent::VSYNC, HWEvent::EXIT, HWEvent::IDLE_NOTIFY,
HWEvent::SHOW_BLANK_EVENT, HWEvent::THERMAL_LEVEL, HWEvent::IDLE_POWER_COLLAPSE }; HWEvent::SHOW_BLANK_EVENT, HWEvent::THERMAL_LEVEL, HWEvent::IDLE_POWER_COLLAPSE };
bool avr_prop_disabled_ = false; bool avr_prop_disabled_ = false;

View File

@@ -254,5 +254,12 @@ DisplayError Strategy::Purge() {
return kErrorNone; return kErrorNone;
} }
DisplayError Strategy::SetIdleTimeoutMs(uint32_t active_ms) {
if (strategy_intf_) {
return strategy_intf_->SetIdleTimeoutMs(active_ms);
}
return kErrorNotSupported;
}
} // namespace sdm } // namespace sdm

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved. * Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted * Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@@ -52,6 +52,7 @@ class Strategy {
const DisplayConfigVariableInfo &fb_config); const DisplayConfigVariableInfo &fb_config);
DisplayError SetCompositionState(LayerComposition composition_type, bool enable); DisplayError SetCompositionState(LayerComposition composition_type, bool enable);
DisplayError Purge(); DisplayError Purge();
DisplayError SetIdleTimeoutMs(uint32_t active_ms);
private: private:
void GenerateROI(); void GenerateROI();

View File

@@ -54,11 +54,15 @@ int Debug::GetHDMIResolution() {
return value; return value;
} }
uint32_t Debug::GetIdleTimeoutMs() { void Debug::GetIdleTimeoutMs(uint32_t *active_ms, uint32_t *inactive_ms) {
int value = IDLE_TIMEOUT_DEFAULT_MS; int active_val = IDLE_TIMEOUT_ACTIVE_MS;
debug_.debug_handler_->GetProperty("sdm.idle_time", &value); int inactive_val = IDLE_TIMEOUT_INACTIVE_MS;
return UINT32(value); debug_.debug_handler_->GetProperty("sdm.idle_time", &active_val);
debug_.debug_handler_->GetProperty("sdm.idle_time.inactive", &inactive_val);
*active_ms = UINT32(active_val);
*inactive_ms = UINT32(inactive_val);
} }
int Debug::GetBootAnimLayerCount() { int Debug::GetBootAnimLayerCount() {