hwc/qdutils/qservice: Add dynamic idle timeout support
Add support for dynamically setting idle timeout values.
Move default idle timeout setting to IdleInvalidator.
Fix static var naming, handle errors from IdleInvalidator in hwc.
Property debug.hwc.idletime is removed with this change.
Example:
1) Set idle timeout to 100ms
adb shell service call display.qservice 16 i32 100
16 is the code for SET_IDLE_TIMEOUT, 100 is time in ms
2) Disable idle timeout
adb shell service call display.qservice 16 i32 0
Change-Id: I60e15a3ac869b4e9f4015b3be50a35c90d00d404
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 82d1f05..937f156 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -36,7 +36,7 @@
//==============MDPComp========================================================
-IdleInvalidator *MDPComp::idleInvalidator = NULL;
+IdleInvalidator *MDPComp::sIdleInvalidator = NULL;
bool MDPComp::sIdleFallBack = false;
bool MDPComp::sHandleTimeout = false;
bool MDPComp::sDebugLogs = false;
@@ -110,7 +110,7 @@
return false;
}
- char property[PROPERTY_VALUE_MAX];
+ char property[PROPERTY_VALUE_MAX] = {0};
sEnabled = false;
if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) &&
@@ -134,23 +134,10 @@
}
if(ctx->mMDP.panel != MIPI_CMD_PANEL) {
- // Idle invalidation is not necessary on command mode panels
- long idle_timeout = DEFAULT_IDLE_TIME;
- if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) {
- if(atoi(property) != 0)
- idle_timeout = atoi(property);
- }
-
- //create Idle Invalidator only when not disabled through property
- if(idle_timeout != -1)
- idleInvalidator = IdleInvalidator::getInstance();
-
- if(idleInvalidator == NULL) {
- ALOGE("%s: failed to instantiate idleInvalidator object",
- __FUNCTION__);
- } else {
- idleInvalidator->init(timeout_handler, ctx,
- (unsigned int)idle_timeout);
+ sIdleInvalidator = IdleInvalidator::getInstance();
+ if(sIdleInvalidator->init(timeout_handler, ctx) < 0) {
+ delete sIdleInvalidator;
+ sIdleInvalidator = NULL;
}
}
@@ -206,6 +193,25 @@
ctx->proc->invalidate(ctx->proc);
}
+void MDPComp::setIdleTimeout(const uint32_t& timeout) {
+ enum { ONE_REFRESH_PERIOD_MS = 17, ONE_BILLION_MS = 1000000000 };
+
+ if(sIdleInvalidator) {
+ if(timeout <= ONE_REFRESH_PERIOD_MS) {
+ //If the specified timeout is < 1 draw cycle worth, "virtually"
+ //disable idle timeout. The ideal way for clients to disable
+ //timeout is to set it to 0
+ sIdleInvalidator->setIdleTimeout(ONE_BILLION_MS);
+ ALOGI("Disabled idle timeout");
+ return;
+ }
+ sIdleInvalidator->setIdleTimeout(timeout);
+ ALOGI("Idle timeout set to %u", timeout);
+ } else {
+ ALOGW("Cannot set idle timeout, IdleInvalidator not enabled");
+ }
+}
+
void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx,
hwc_display_contents_1_t* list) {
LayerProp *layerProp = ctx->layerProp[mDpy];
@@ -2055,7 +2061,7 @@
}
// Set the Handle timeout to true for MDP or MIXED composition.
- if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) {
+ if(sIdleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) {
sHandleTimeout = true;
}
@@ -2310,7 +2316,7 @@
}
// Set the Handle timeout to true for MDP or MIXED composition.
- if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) {
+ if(sIdleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) {
sHandleTimeout = true;
}