diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp index ab11bc47..31d4b2e9 100644 --- a/libhwcomposer/hwc_mdpcomp.cpp +++ b/libhwcomposer/hwc_mdpcomp.cpp @@ -591,18 +591,8 @@ bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - mCurrentFrame.dropCount; - if(mCurrentFrame.mdpCount > sMaxPipesPerMixer) { - ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); - return false; - } - - if(!arePipesAvailable(ctx, list)) { - return false; - } - - uint32_t size = calcMDPBytesRead(ctx, list); - if(!bandwidthCheck(ctx, size)) { - ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); + if(!resourceCheck(ctx, list)) { + ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); return false; } @@ -662,18 +652,8 @@ bool MDPComp::cacheBasedComp(hwc_context_t *ctx, return false; } - if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used - ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); - return false; - } - - if(!arePipesAvailable(ctx, list)) { - return false; - } - - uint32_t size = calcMDPBytesRead(ctx, list); - if(!bandwidthCheck(ctx, size)) { - ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); + if(!resourceCheck(ctx, list)) { + ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); return false; } @@ -733,7 +713,8 @@ bool MDPComp::loadBasedComp(hwc_context_t *ctx, mCurrentFrame.fbCount = batchSize; mCurrentFrame.mdpCount = mCurrentFrame.layerCount - batchSize; - if(!arePipesAvailable(ctx, list)) { + if(!resourceCheck(ctx, list)) { + ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); return false; } @@ -773,18 +754,8 @@ bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, if(!mdpCount) return false; - if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { - ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); - return false; - } - - if(!arePipesAvailable(ctx, list)) { - return false; - } - - uint32_t size = calcMDPBytesRead(ctx, list); - if(!bandwidthCheck(ctx, size)) { - ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); + if(!resourceCheck(ctx, list)) { + ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); return false; } @@ -1108,6 +1079,27 @@ bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { return true; } +bool MDPComp::resourceCheck(hwc_context_t *ctx, + hwc_display_contents_1_t *list) { + const bool fbUsed = mCurrentFrame.fbCount; + if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { + ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); + return false; + } + + if(!arePipesAvailable(ctx, list)) { + return false; + } + + uint32_t size = calcMDPBytesRead(ctx, list); + if(!bandwidthCheck(ctx, size)) { + ALOGD_IF(isDebug(), "%s: Exceeds bandwidth",__FUNCTION__); + return false; + } + + return true; +} + uint32_t MDPComp::calcMDPBytesRead(hwc_context_t *ctx, hwc_display_contents_1_t* list) { uint32_t size = 0; diff --git a/libhwcomposer/hwc_mdpcomp.h b/libhwcomposer/hwc_mdpcomp.h index 1d5d715a..a7faff33 100644 --- a/libhwcomposer/hwc_mdpcomp.h +++ b/libhwcomposer/hwc_mdpcomp.h @@ -192,6 +192,7 @@ protected: bool programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list); void reset(const int& numAppLayers, hwc_display_contents_1_t* list); bool isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer); + bool resourceCheck(hwc_context_t *ctx, hwc_display_contents_1_t *list); int mDpy; static bool sEnabled;