Merge "display: Return MDP pipe availability per display type"
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index c65c056..2c0a77a 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -369,7 +369,7 @@
int numAppLayers = ctx->listStats[dpy].numAppLayers;
overlay::Overlay& ov = *ctx->mOverlay;
- int availablePipes = ov.availablePipes();
+ int availablePipes = ov.availablePipes(dpy);
if(numAppLayers < 1 || numAppLayers > (uint32_t)availablePipes) {
ALOGD_IF(isDebug(), "%s: Unsupported number of layers",__FUNCTION__);
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 2378889..151cfb3 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -71,8 +71,8 @@
static void initOverlay();
/* Returns the singleton instance of overlay */
static Overlay* getInstance();
- /* Returns total of available ("unallocated") pipes */
- static int availablePipes();
+ /* Returns available ("unallocated") pipes for a display */
+ int availablePipes(int dpy);
/* set the framebuffer index for external display */
void setExtFbNum(int fbNum);
/* Returns framebuffer index of the current external display */
@@ -111,8 +111,6 @@
static void resetAllocation(int index);
static bool isAllocated(int index);
static bool isNotAllocated(int index);
- /* Returns total of available ("unallocated") pipes */
- static int availablePipes();
static int NUM_PIPES;
@@ -149,8 +147,15 @@
utils::getDestStr((utils::eDest)index));
}
-inline int Overlay::availablePipes() {
- return PipeBook::availablePipes();
+inline int Overlay::availablePipes(int dpy) {
+ int avail = 0;
+ for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
+ if((mPipeBook[i].mDisplay == PipeBook::DPY_UNUSED ||
+ mPipeBook[i].mDisplay == dpy) && PipeBook::isNotAllocated(i)) {
+ avail++;
+ }
+ }
+ return avail;
}
inline void Overlay::setExtFbNum(int fbNum) {
@@ -163,16 +168,6 @@
return sExtFbIndex;
}
-inline int Overlay::PipeBook::availablePipes() {
- int used = 0;
- int bmp = sAllocatedBitmap;
- for(; bmp; used++) {
- //clearing from lsb
- bmp = bmp & (bmp - 1);
- }
- return NUM_PIPES - used;
-}
-
inline bool Overlay::PipeBook::valid() {
return (mPipe != NULL);
}