hwc: Configure framebuffer before other layers.
If framebuffer needs to be configured, configure it before all the
other layers in mdp composition. This helps in cases where we are
out of SMPs and framebuffer configuration fails owing to that.
Framebuffer being the fallback path, should always get highest
priority when reserving SMP blocks
Change-Id: Ie7a6903d1b9fb98b308689c81522571449bf2e8e
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 2ab9491..0f34cd4 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -22,6 +22,7 @@
#include "external.h"
#include "qdMetaData.h"
#include "mdp_version.h"
+#include "hwc_fbupdate.h"
#include <overlayRotator.h>
using namespace overlay;
@@ -137,6 +138,12 @@
return true;
}
+void MDPComp::reset(const int& numLayers, hwc_display_contents_1_t* list) {
+ mCurrentFrame.reset(numLayers);
+ mCachedFrame.cacheAll(list);
+ mCachedFrame.updateCounts(mCurrentFrame);
+}
+
void MDPComp::timeout_handler(void *udata) {
struct hwc_context_t* ctx = (struct hwc_context_t*)(udata);
@@ -748,7 +755,6 @@
}
int MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
-
const int numLayers = ctx->listStats[mDpy].numAppLayers;
{ //LOCK SCOPE BEGIN
@@ -763,26 +769,33 @@
mCachedFrame.updateCounts(mCurrentFrame);
ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ",
__FUNCTION__);
- return 0;
+ return -1;
}
//Hard conditions, if not met, cannot do MDP comp
if(!isFrameDoable(ctx)) {
ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame",
__FUNCTION__);
- mCurrentFrame.reset(numLayers);
- mCachedFrame.cacheAll(list);
- mCachedFrame.updateCounts(mCurrentFrame);
- return 0;
+ reset(numLayers, list);
+ return -1;
}
//Check whether layers marked for MDP Composition is actually doable.
if(isFullFrameDoable(ctx, list)){
mCurrentFrame.map();
+ //Configure framebuffer first if applicable
+ if(mCurrentFrame.fbZ >= 0) {
+ if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list,
+ mCurrentFrame.fbZ)) {
+ ALOGE("%s configure framebuffer failed", __func__);
+ reset(numLayers, list);
+ return -1;
+ }
+ }
//Acquire and Program MDP pipes
if(!programMDP(ctx, list)) {
- mCurrentFrame.reset(numLayers);
- mCachedFrame.cacheAll(list);
+ reset(numLayers, list);
+ return -1;
} else { //Success
//Any change in composition types needs an FB refresh
mCurrentFrame.needsRedraw = false;
@@ -807,13 +820,22 @@
mCurrentFrame.fbZ = mCurrentFrame.mdpCount;
mCurrentFrame.map();
+
+ //Configure framebuffer first if applicable
+ if(mCurrentFrame.fbZ >= 0) {
+ if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, mCurrentFrame.fbZ)) {
+ ALOGE("%s configure framebuffer failed", __func__);
+ reset(numLayers, list);
+ return -1;
+ }
+ }
if(!programYUV(ctx, list)) {
- mCurrentFrame.reset(numLayers);
- mCachedFrame.cacheAll(list);
+ reset(numLayers, list);
+ return -1;
}
} else {
- mCurrentFrame.reset(numLayers);
- mCachedFrame.cacheAll(list);
+ reset(numLayers, list);
+ return -1;
}
//UpdateLayerFlags
@@ -829,7 +851,7 @@
ALOGE("%s",sDump.string());
}
- return mCurrentFrame.fbZ;
+ return 0;
}
//=============MDPCompLowRes===================================================