hwc: Configure pipe for FB even if we exceed max layers
Even if we exceed max supported layers, configure pipe for FB
Because FB contents are always displayed using hwc
Also some minor code fixes
Change-Id: I740ab7e908c916373b1d87facd831e09098ce753
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index fccfcde..bc705ac 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -108,17 +108,12 @@
}
//clear prev layer prop flags and realloc for current frame
-static void reset_layer_prop(hwc_context_t* ctx, int dpy) {
- int layer_count = ctx->listStats[dpy].numAppLayers;
-
+static void reset_layer_prop(hwc_context_t* ctx, int dpy, int numAppLayers) {
if(ctx->layerProp[dpy]) {
delete[] ctx->layerProp[dpy];
ctx->layerProp[dpy] = NULL;
}
-
- if(layer_count) {
- ctx->layerProp[dpy] = new LayerProp[layer_count];
- }
+ ctx->layerProp[dpy] = new LayerProp[numAppLayers];
}
static int display_commit(hwc_context_t *ctx, int dpy) {
@@ -136,23 +131,27 @@
hwc_display_contents_1_t *list) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
const int dpy = HWC_DISPLAY_PRIMARY;
- if (LIKELY(list && list->numHwLayers > 1 &&
- list->numHwLayers <= MAX_NUM_LAYERS) && ctx->dpyAttr[dpy].isActive) {
+ if (LIKELY(list && list->numHwLayers > 1) &&
+ ctx->dpyAttr[dpy].isActive) {
+ reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
uint32_t last = list->numHwLayers - 1;
hwc_layer_1_t *fbLayer = &list->hwLayers[last];
if(fbLayer->handle) {
+ if(list->numHwLayers > MAX_NUM_LAYERS) {
+ ctx->mFBUpdate[dpy]->prepare(ctx, list);
+ return 0;
+ }
setListStats(ctx, list, dpy);
- reset_layer_prop(ctx, dpy);
- int ret = ctx->mMDPComp->prepare(ctx, list);
+ bool ret = ctx->mMDPComp->prepare(ctx, list);
if(!ret) {
// IF MDPcomp fails use this route
ctx->mVidOv[dpy]->prepare(ctx, list);
ctx->mFBUpdate[dpy]->prepare(ctx, list);
+ // Use Copybit, when MDP comp fails
+ if(ctx->mCopyBit[dpy])
+ ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
+ ctx->mLayerCache[dpy]->updateLayerCache(list);
}
- ctx->mLayerCache[dpy]->updateLayerCache(list);
- // Use Copybit, when MDP comp fails
- if(!ret && ctx->mCopyBit[dpy])
- ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
}
}
return 0;
@@ -162,22 +161,25 @@
hwc_display_contents_1_t *list, int dpy) {
hwc_context_t* ctx = (hwc_context_t*)(dev);
- if (LIKELY(list && list->numHwLayers > 1 &&
- list->numHwLayers <= MAX_NUM_LAYERS) &&
- ctx->dpyAttr[dpy].isActive &&
- ctx->dpyAttr[dpy].connected) {
+ if (LIKELY(list && list->numHwLayers > 1) &&
+ ctx->dpyAttr[dpy].isActive &&
+ ctx->dpyAttr[dpy].connected) {
+ reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
uint32_t last = list->numHwLayers - 1;
+ hwc_layer_1_t *fbLayer = &list->hwLayers[last];
if(!ctx->dpyAttr[dpy].isPause) {
- hwc_layer_1_t *fbLayer = &list->hwLayers[last];
if(fbLayer->handle) {
+ ctx->mExtDispConfiguring = false;
+ if(list->numHwLayers > MAX_NUM_LAYERS) {
+ ctx->mFBUpdate[dpy]->prepare(ctx, list);
+ return 0;
+ }
setListStats(ctx, list, dpy);
- reset_layer_prop(ctx, dpy);
ctx->mVidOv[dpy]->prepare(ctx, list);
ctx->mFBUpdate[dpy]->prepare(ctx, list);
ctx->mLayerCache[dpy]->updateLayerCache(list);
if(ctx->mCopyBit[dpy])
ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
- ctx->mExtDispConfiguring = false;
}
} else {
// External Display is in Pause state.
@@ -362,19 +364,15 @@
//TODO We dont check for SKIP flag on this layer because we need PAN
//always. Last layer is always FB
- private_handle_t *hnd = NULL;
+ private_handle_t *hnd = (private_handle_t *)fbLayer->handle;
if(copybitDone) {
hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer();
- } else {
- hnd = (private_handle_t *)fbLayer->handle;
}
- if(fbLayer->compositionType == HWC_FRAMEBUFFER_TARGET && hnd) {
- if(!(fbLayer->flags & HWC_SKIP_LAYER) &&
- (list->numHwLayers > 1)) {
- if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) {
- ALOGE("%s: FBUpdate draw failed", __FUNCTION__);
- ret = -1;
- }
+
+ if(hnd) {
+ if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) {
+ ALOGE("%s: FBUpdate draw failed", __FUNCTION__);
+ ret = -1;
}
}
@@ -413,16 +411,12 @@
ret = -1;
}
- private_handle_t *hnd = NULL;
+ private_handle_t *hnd = (private_handle_t *)fbLayer->handle;
if(copybitDone) {
hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer();
- } else {
- hnd = (private_handle_t *)fbLayer->handle;
}
- if(fbLayer->compositionType == HWC_FRAMEBUFFER_TARGET &&
- !(fbLayer->flags & HWC_SKIP_LAYER) && hnd &&
- (list->numHwLayers > 1)) {
+ if(hnd) {
if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) {
ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__);
ret = -1;
@@ -431,7 +425,7 @@
if (display_commit(ctx, dpy) < 0) {
ALOGE("%s: display commit fail!", __FUNCTION__);
- return -1;
+ ret = -1;
}
}