hwc: Add BWC policy manager
Add a BWC policy manager that decides if BWC needs to be disabled on
certain conditions.
These conditions are statically determined. BWC might get used and
still fail (or cause failure of subsequent pipe requests) if SMP
blocks are not sufficient.
Change-Id: I805738911a8da7dfc6232c133c74ef844c3af5b1
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index b33b744..14b733a 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -728,12 +728,6 @@
if(transform & HWC_TRANSFORM_ROT_90) {
ovutils::setMdpFlags(mdpFlags,
ovutils::OV_MDP_SOURCE_ROTATED_90);
- // enable bandwidth compression only if src width < 2048
- if(qdutils::MDPVersion::getInstance().supportsBWC() &&
- hnd->width < qdutils::MAX_DISPLAY_DIM) {
- ovutils::setMdpFlags(mdpFlags,
- ovutils::OV_MDSS_MDP_BWC_EN);
- }
}
}
@@ -911,6 +905,7 @@
((transform & HWC_TRANSFORM_ROT_90) || downscale)) {
*rot = ctx->mRotMgr->getNext();
if(*rot == NULL) return -1;
+ BwcPM::setBwc(ctx, crop, dst, transform, mdpFlags);
//Configure rotator for pre-rotation
if(configRotator(*rot, whf, crop, mdpFlags, orient, downscale) < 0) {
ALOGE("%s: configRotator failed!", __FUNCTION__);
@@ -1077,4 +1072,43 @@
return true;
}
+
+void BwcPM::setBwc(hwc_context_t *ctx, const hwc_rect_t& crop,
+ const hwc_rect_t& dst, const int& transform,
+ ovutils::eMdpFlags& mdpFlags) {
+ //Target doesnt support Bwc
+ if(!qdutils::MDPVersion::getInstance().supportsBWC()) {
+ return;
+ }
+ //src width > MAX mixer supported dim
+ if((crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) {
+ return;
+ }
+ //External connected
+ if(ctx->mExtDisplay->isExternalConnected()) {
+ return;
+ }
+ //Decimation necessary, cannot use BWC. H/W requirement.
+ if(qdutils::MDPVersion::getInstance().supportsDecimation()) {
+ int src_w = crop.right - crop.left;
+ int src_h = crop.bottom - crop.top;
+ int dst_w = dst.right - dst.left;
+ int dst_h = dst.bottom - dst.top;
+ if(transform & HAL_TRANSFORM_ROT_90) {
+ swap(src_w, src_h);
+ }
+ float horDscale = 0.0f;
+ float verDscale = 0.0f;
+ ovutils::getDecimationFactor(src_w, src_h, dst_w, dst_h, horDscale,
+ verDscale);
+ if(horDscale || verDscale) return;
+ }
+ //Property
+ char value[PROPERTY_VALUE_MAX];
+ property_get("debug.disable.bwc", value, "0");
+ if(atoi(value)) return;
+
+ ovutils::setMdpFlags(mdpFlags, ovutils::OV_MDSS_MDP_BWC_EN);
+}
+
};//namespace qhwc