hwc: Move resource checks to a common function.
Move resource checks, pipes, stages of mixer, bandwidth to a common
function and use it from all strategies.
Change-Id: I161fc957e2793d543b5943fbd23ae3607a4cfc87
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index ab11bc4..31d4b2e 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -591,18 +591,8 @@
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 @@
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 @@
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 @@
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 @@
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;