hwc: mdpcomp: split: Count total pipes needed per display also
When checking for pipes needed for each mixer, the pipes completely
unused are counted twice.
Add a per display check on top of per mixer check to make sure this
is taken care of.
For example: Each mixer needs 4 pipes, and total completely unused
pipes are 6. Each mixer will get 6 as available pipes, which is ok
at a mixer level, but at a display level 8 pipes are needed and 6
available. Need to account for that
Change-Id: I9811255aab96c7fe47331f8aa125fef2a4a2f704
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 0772f80..9713835 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -1058,6 +1058,7 @@
bool MDPCompSplit::arePipesAvailable(hwc_context_t *ctx,
hwc_display_contents_1_t* list) {
overlay::Overlay& ov = *ctx->mOverlay;
+ int totalPipesNeeded = 0;
for(int i = 0; i < Overlay::MIXER_MAX; i++) {
int numPipesNeeded = pipesNeeded(ctx, list, i);
@@ -1065,8 +1066,11 @@
//Reserve pipe(s)for FB
if(mCurrentFrame.fbCount)
- availPipes -= 1;
+ numPipesNeeded += 1;
+ totalPipesNeeded += numPipesNeeded;
+
+ //Per mixer check.
if(numPipesNeeded > availPipes) {
ALOGD_IF(isDebug(), "%s: Insufficient pipes for "
"dpy %d mixer %d needed %d, avail %d",
@@ -1074,6 +1078,16 @@
return false;
}
}
+
+ //Per display check, since unused pipes can get counted twice.
+ int totalPipesAvailable = ov.availablePipes(mDpy);
+ if(totalPipesNeeded > totalPipesAvailable) {
+ ALOGD_IF(isDebug(), "%s: Insufficient pipes for "
+ "dpy %d needed %d, avail %d",
+ __FUNCTION__, mDpy, totalPipesNeeded, totalPipesAvailable);
+ return false;
+ }
+
return true;
}
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 280223c..4b91038 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -84,6 +84,8 @@
/* Returns available ("unallocated") pipes for a display's mixer */
int availablePipes(int dpy, int mixer);
+ /* Returns available ("unallocated") pipes for a display */
+ int availablePipes(int dpy);
/* Returns if any of the requested pipe type is attached to any of the
* displays
*/
@@ -198,6 +200,21 @@
return avail;
}
+inline int Overlay::availablePipes(int dpy) {
+ int avail = 0;
+ for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
+ if( (mPipeBook[i].mDisplay == DPY_UNUSED ||
+ mPipeBook[i].mDisplay == dpy) &&
+ PipeBook::isNotAllocated(i) &&
+ !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE &&
+ PipeBook::getPipeType((utils::eDest)i) ==
+ utils::OV_MDP_PIPE_DMA)) {
+ avail++;
+ }
+ }
+ return avail;
+}
+
inline void Overlay::setDMAMode(const int& mode) {
if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE)
sDMAMode = mode;