hwc_mdpcomp.cpp revision b64922f99edce921000e0aaf17bd3bcb686910d1
1c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed/* 2404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved. 3c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * Not a Contribution, Apache license notifications and license are retained 4c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * for attribution purposes only. 5c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * 6c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * Licensed under the Apache License, Version 2.0 (the "License"); 7c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * you may not use this file except in compliance with the License. 8c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * You may obtain a copy of the License at 9c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * 10c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * http://www.apache.org/licenses/LICENSE-2.0 11c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * 12c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * Unless required by applicable law or agreed to in writing, software 13c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * distributed under the License is distributed on an "AS IS" BASIS, 14c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * See the License for the specific language governing permissions and 16c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * limitations under the License. 17c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed */ 18c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1941269096daf2363b16dcd89627dd674529a26601Saurabh Shah#include <math.h> 20c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed#include "hwc_mdpcomp.h" 2116791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed#include <sys/ioctl.h> 22bbee5b1c3475b630caa5061fbf535f87f21743f7Saurabh Shah#include "external.h" 23361900d9a618d2c4d2276a10ca76919214f6759fJeykumar Sankaran#include "virtual.h" 24591f83eb35f33cf108720d9bb30cb56933e1e724Ramkumar Radhakrishnan#include "qdMetaData.h" 258b2d50f3c665329517352269a687bdf562b2cc6dRamkumar Radhakrishnan#include "mdp_version.h" 26699929775d0f2612670fe7f07ceda438c7f7d502Saurabh Shah#include "hwc_fbupdate.h" 27f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah#include "hwc_ad.h" 28327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah#include <overlayRotator.h> 29c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 3011154eed0599cd2e03bd0706341e14e05265b907Saurabh Shahusing namespace overlay; 318fe8c938d27e528fcf7fb4a408711b4b6e405f13Saurabh Shahusing namespace qdutils; 32327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shahusing namespace overlay::utils; 3316791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmednamespace ovutils = overlay::utils; 34c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 35327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shahnamespace qhwc { 36327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 37c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah//==============MDPComp======================================================== 38c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 39c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer AhmedIdleInvalidator *MDPComp::idleInvalidator = NULL; 40c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmedbool MDPComp::sIdleFallBack = false; 41e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnanbool MDPComp::sHandleTimeout = false; 42c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmedbool MDPComp::sDebugLogs = false; 4316791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmedbool MDPComp::sEnabled = false; 44e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaranbool MDPComp::sEnableMixedMode = true; 45bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaranbool MDPComp::sEnablePartialFrameUpdate = false; 46f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranint MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; 4715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishnabool MDPComp::sEnable4k2kYUVSplit = false; 48c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVMbool MDPComp::sSrcSplitEnabled = false; 49f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh ShahMDPComp* MDPComp::getObject(hwc_context_t *ctx, const int& dpy) { 50c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM 51f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah if(isDisplaySplit(ctx, dpy)) { 527dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(qdutils::MDPVersion::getInstance().isSrcSplit()) { 53c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM sSrcSplitEnabled = true; 547dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return new MDPCompSrcSplit(dpy); 557dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 56f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return new MDPCompSplit(dpy); 57c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 58f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return new MDPCompNonSplit(dpy); 59c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 6016791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed 61f9572cdbe3541d85522adea584f925671b375300Jeykumar SankaranMDPComp::MDPComp(int dpy):mDpy(dpy){}; 62f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 63c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shahvoid MDPComp::dump(android::String8& buf) 64c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah{ 65bae2ff236d510b0ffad6d5caf3b90bef794ce66fJeykumar Sankaran if(mCurrentFrame.layerCount > MAX_NUM_APP_LAYERS) 66bae2ff236d510b0ffad6d5caf3b90bef794ce66fJeykumar Sankaran return; 67bae2ff236d510b0ffad6d5caf3b90bef794ce66fJeykumar Sankaran 68f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf,"HWC Map for Dpy: %s \n", 69361900d9a618d2c4d2276a10ca76919214f6759fJeykumar Sankaran (mDpy == 0) ? "\"PRIMARY\"" : 70361900d9a618d2c4d2276a10ca76919214f6759fJeykumar Sankaran (mDpy == 1) ? "\"EXTERNAL\"" : "\"VIRTUAL\""); 71efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d " 72efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah "fbCount:%2d \n", mCurrentFrame.layerCount, 73f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.mdpCount, mCurrentFrame.fbCount); 74f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", 75f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (mCurrentFrame.needsRedraw? "YES" : "NO"), 76f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.mdpCount, sMaxPipesPerMixer); 77f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf," --------------------------------------------- \n"); 78f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); 79f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf," --------------------------------------------- \n"); 80f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int index = 0; index < mCurrentFrame.layerCount; index++ ) 81f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", 82f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran index, 83f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), 84bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.layerToMDP[index], 85f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (mCurrentFrame.isFBComposed[index] ? 86bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran (mCurrentFrame.drop[index] ? "DROP" : 87bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran (mCurrentFrame.needsRedraw ? "GLES" : "CACHE")) : "MDP"), 88f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : 89f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); 90f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dumpsys_log(buf,"\n"); 91c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah} 92c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 93c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shahbool MDPComp::init(hwc_context_t *ctx) { 94c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 95c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah if(!ctx) { 96c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah ALOGE("%s: Invalid hwc context!!",__FUNCTION__); 97c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah return false; 98c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 99c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 100c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah char property[PROPERTY_VALUE_MAX]; 101c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 102c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah sEnabled = false; 103c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && 104f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || 105f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { 106c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah sEnabled = true; 107c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 108c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 109e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran sEnableMixedMode = true; 110e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) && 111e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || 112e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { 113e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran sEnableMixedMode = false; 114e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran } 115e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran 116c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { 117c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah if(atoi(property) != 0) 118c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah sDebugLogs = true; 119c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 120c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 121bc35f9e7e36658230062bdb96f1ea51798c699b7Jeykumar Sankaran if(property_get("persist.hwc.partialupdate", property, NULL) > 0) { 122bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if((atoi(property) != 0) && ctx->mMDP.panel == MIPI_CMD_PANEL && 123bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran qdutils::MDPVersion::getInstance().is8x74v2()) 124bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran sEnablePartialFrameUpdate = true; 125bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 126bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ALOGE_IF(isDebug(), "%s: Partial Update applicable?: %d",__FUNCTION__, 127bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran sEnablePartialFrameUpdate); 128bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 129f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; 13011154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { 13111154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah int val = atoi(property); 13211154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah if(val >= 0) 13311154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); 134f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 135f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1366bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed if(ctx->mMDP.panel != MIPI_CMD_PANEL) { 1376bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed // Idle invalidation is not necessary on command mode panels 1386bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed long idle_timeout = DEFAULT_IDLE_TIME; 1396bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { 1406bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed if(atoi(property) != 0) 1416bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed idle_timeout = atoi(property); 1426bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed } 143c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 1446bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed //create Idle Invalidator only when not disabled through property 1456bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed if(idle_timeout != -1) 1466bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed idleInvalidator = IdleInvalidator::getInstance(); 147c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 1486bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed if(idleInvalidator == NULL) { 1496bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed ALOGE("%s: failed to instantiate idleInvalidator object", 1506bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed __FUNCTION__); 1516bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed } else { 1523d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu idleInvalidator->init(timeout_handler, ctx, 1533d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu (unsigned int)idle_timeout); 1546bdc0c9dd2e7dbd8b6fafc7a94f05889a3abf5f1Naseer Ahmed } 155c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 15615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 15715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if((property_get("debug.mdpcomp.4k2kSplit", property, "0") > 0) && 15815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || 15915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { 16015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna sEnable4k2kYUVSplit = true; 16115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 162c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah return true; 163c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah} 164c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 165c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahvoid MDPComp::reset(hwc_context_t *ctx) { 166c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah const int numLayers = ctx->listStats[mDpy].numAppLayers; 167699929775d0f2612670fe7f07ceda438c7f7d502Saurabh Shah mCurrentFrame.reset(numLayers); 168c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ctx->mOverlay->clear(mDpy); 169c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ctx->mLayerRotMap[mDpy]->clear(); 170699929775d0f2612670fe7f07ceda438c7f7d502Saurabh Shah} 171699929775d0f2612670fe7f07ceda438c7f7d502Saurabh Shah 172c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmedvoid MDPComp::timeout_handler(void *udata) { 173c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); 174c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 175c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed if(!ctx) { 176c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed ALOGE("%s: received empty data in timer callback", __FUNCTION__); 177c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed return; 178c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 179e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan Locker::Autolock _l(ctx->mDrawLock); 180e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan // Handle timeout event only if the previous composition is MDP or MIXED. 181e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan if(!sHandleTimeout) { 182e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan ALOGD_IF(isDebug(), "%s:Do not handle this timeout", __FUNCTION__); 183e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan return; 184e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan } 185359c544e1ca5ad76be326d9ee809e7bee51f94b4Jesse Hall if(!ctx->proc) { 186c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed ALOGE("%s: HWC proc not registered", __FUNCTION__); 187c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed return; 188c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 189c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed sIdleFallBack = true; 190c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed /* Trigger SF to redraw the current frame */ 191359c544e1ca5ad76be326d9ee809e7bee51f94b4Jesse Hall ctx->proc->invalidate(ctx->proc); 192c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 193c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 194c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shahvoid MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, 195f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran hwc_display_contents_1_t* list) { 196f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran LayerProp *layerProp = ctx->layerProp[mDpy]; 197c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 198f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { 199c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah hwc_layer_1_t* layer = &(list->hwLayers[index]); 200f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!mCurrentFrame.isFBComposed[index]) { 201f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran layerProp[index].mFlags |= HWC_MDPCOMP; 202f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran layer->compositionType = HWC_OVERLAY; 203f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran layer->hints |= HWC_HINT_CLEAR_FB; 204f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } else { 205bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran /* Drop the layer when its already present in FB OR when it lies 206bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran * outside frame's ROI */ 207bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!mCurrentFrame.needsRedraw || mCurrentFrame.drop[index]) { 208f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran layer->compositionType = HWC_OVERLAY; 209bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 210c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 211c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 212c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 21316791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed 214c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahvoid MDPComp::setRedraw(hwc_context_t *ctx, 215c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah hwc_display_contents_1_t* list) { 216c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.needsRedraw = false; 217c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!mCachedFrame.isSameFrame(mCurrentFrame, list) || 218c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah (list->flags & HWC_GEOMETRY_CHANGED) || 219c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah isSkipPresent(ctx, mDpy)) { 220c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.needsRedraw = true; 221c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah } 222c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah} 223c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 224f9572cdbe3541d85522adea584f925671b375300Jeykumar SankaranMDPComp::FrameInfo::FrameInfo() { 225af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah reset(0); 226f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 227c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 228af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahvoid MDPComp::FrameInfo::reset(const int& numLayers) { 229af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) { 230f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mdpToLayer[i].pipeInfo) { 231f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran delete mdpToLayer[i].pipeInfo; 232f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mdpToLayer[i].pipeInfo = NULL; 233f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran //We dont own the rotator 234f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mdpToLayer[i].rot = NULL; 235c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 236c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 237f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 238f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran memset(&mdpToLayer, 0, sizeof(mdpToLayer)); 239f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran memset(&layerToMDP, -1, sizeof(layerToMDP)); 240af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah memset(&isFBComposed, 1, sizeof(isFBComposed)); 241f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 242af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah layerCount = numLayers; 243af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah fbCount = numLayers; 244f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mdpCount = 0; 245ab1a610e5f7858d4ade5795bf075295d33664999Saurabh Shah needsRedraw = true; 2462b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah fbZ = -1; 247f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 248f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 249af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahvoid MDPComp::FrameInfo::map() { 250af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah // populate layer and MDP maps 251af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah int mdpIdx = 0; 252af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah for(int idx = 0; idx < layerCount; idx++) { 253af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah if(!isFBComposed[idx]) { 254af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mdpToLayer[mdpIdx].listIndex = idx; 255af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah layerToMDP[idx] = mdpIdx++; 256af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 257af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 258af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 259af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 260f9572cdbe3541d85522adea584f925671b375300Jeykumar SankaranMDPComp::LayerCache::LayerCache() { 261f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran reset(); 262f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 263f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 264f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranvoid MDPComp::LayerCache::reset() { 265af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah memset(&hnd, 0, sizeof(hnd)); 26687957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula memset(&isFBComposed, true, sizeof(isFBComposed)); 26787957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula memset(&drop, false, sizeof(drop)); 268f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran layerCount = 0; 269af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 270af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 271af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahvoid MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) { 2723d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu const int numAppLayers = (int)list->numHwLayers - 1; 273af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah for(int i = 0; i < numAppLayers; i++) { 274af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah hnd[i] = list->hwLayers[i].handle; 275af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 276af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 277af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 278af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahvoid MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { 279af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah layerCount = curFrame.layerCount; 28087957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula memcpy(&isFBComposed, &curFrame.isFBComposed, sizeof(isFBComposed)); 28187957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula memcpy(&drop, &curFrame.drop, sizeof(drop)); 28287957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula} 28387957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula 284e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaranbool MDPComp::LayerCache::isSameFrame(const FrameInfo& curFrame, 285e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaran hwc_display_contents_1_t* list) { 28687957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula if(layerCount != curFrame.layerCount) 28787957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula return false; 28887957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula for(int i = 0; i < curFrame.layerCount; i++) { 28987957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula if((curFrame.isFBComposed[i] != isFBComposed[i]) || 29087957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula (curFrame.drop[i] != drop[i])) { 29187957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula return false; 29287957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula } 293e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaran if(curFrame.isFBComposed[i] && 294e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaran (hnd[i] != list->hwLayers[i].handle)){ 295e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaran return false; 296e21d2bb081af1c4c05c4a5df0b6306eca09e5f66Jeykumar Sankaran } 29787957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula } 29887957481f22edffdc0b865189807380d75579a12Prabhanjan Kandula return true; 299c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah} 300c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 301efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shahbool MDPComp::isSupportedForMDPComp(hwc_context_t *ctx, hwc_layer_1_t* layer) { 302efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 303efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if((not isYuvBuffer(hnd) and has90Transform(layer)) or 304efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah (not isValidDimension(ctx,layer)) 305efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah //More conditions here, SKIP, sRGB+Blend etc 306efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ) { 307efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 308efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 309efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return true; 310efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah} 311efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 3121b9b395878eee6052ce3c382c4a3067b5adb13c4Sravan Kumar D.V.Nbool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { 3130ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran private_handle_t *hnd = (private_handle_t *)layer->handle; 3140ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 3150ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran if(!hnd) { 31608cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan if (layer->flags & HWC_COLOR_FILL) { 31708cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan // Color layer 31808cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan return true; 31908cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan } 3200ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran ALOGE("%s: layer handle is NULL", __FUNCTION__); 3210ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran return false; 3220ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran } 3230ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 32480864f9daffae7750e05efe41f63e029f5699511Naseer Ahmed //XXX: Investigate doing this with pixel phase on MDSS 3258d07dd7a9493c19215acf1e992502d1f51329fe0Naseer Ahmed if(!isSecureBuffer(hnd) && isNonIntegralSourceCrop(layer->sourceCropf)) 32680864f9daffae7750e05efe41f63e029f5699511Naseer Ahmed return false; 32780864f9daffae7750e05efe41f63e029f5699511Naseer Ahmed 3288f42508dc1e3bf24da360d5fbefd8c6574f82868Saurabh Shah hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); 32941269096daf2363b16dcd89627dd674529a26601Saurabh Shah hwc_rect_t dst = layer->displayFrame; 3300ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran int crop_w = crop.right - crop.left; 3310ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran int crop_h = crop.bottom - crop.top; 3320ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran int dst_w = dst.right - dst.left; 3330ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran int dst_h = dst.bottom - dst.top; 334df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran float w_scale = ((float)crop_w / (float)dst_w); 335df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran float h_scale = ((float)crop_h / (float)dst_h); 3360ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 337f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran /* Workaround for MDP HW limitation in DSI command mode panels where 338f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran * FPS will not go beyond 30 if buffers on RGB pipes are of width or height 339f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran * less than 5 pixels 3401b9b395878eee6052ce3c382c4a3067b5adb13c4Sravan Kumar D.V.N * There also is a HW limilation in MDP, minimum block size is 2x2 3411b9b395878eee6052ce3c382c4a3067b5adb13c4Sravan Kumar D.V.N * Fallback to GPU if height is less than 2. 3421b9b395878eee6052ce3c382c4a3067b5adb13c4Sravan Kumar D.V.N */ 343f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if((crop_w < 5)||(crop_h < 5)) 3440ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran return false; 3450ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 346df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran if((w_scale > 1.0f) || (h_scale > 1.0f)) { 347c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM const uint32_t maxMDPDownscale = 34841269096daf2363b16dcd89627dd674529a26601Saurabh Shah qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); 349df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran const float w_dscale = w_scale; 350df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran const float h_dscale = h_scale; 351df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran 352bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran if(ctx->mMDP.version >= qdutils::MDSS_V5) { 353c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM 354bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { 355c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM /* On targets that doesnt support Decimation (eg.,8x26) 356c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM * maximum downscale support is overlay pipe downscale. 357c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM */ 358c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM if(crop_w > MAX_DISPLAY_DIM || w_dscale > maxMDPDownscale || 359c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM h_dscale > maxMDPDownscale) 360bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran return false; 361bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran } else { 362c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM // Decimation on macrotile format layers is not supported. 363c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM if(isTileRendered(hnd)) { 364c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM /* MDP can read maximum MAX_DISPLAY_DIM width. 365c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM * Bail out if 366c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM * 1. Src crop > MAX_DISPLAY_DIM on nonsplit MDPComp 367c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM * 2. exceeds maximum downscale limit 368c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM */ 369c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM if(((crop_w > MAX_DISPLAY_DIM) && !sSrcSplitEnabled) || 370c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM w_dscale > maxMDPDownscale || 371c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM h_dscale > maxMDPDownscale) { 372c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM return false; 373c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM } 374c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM } else if(w_dscale > 64 || h_dscale > 64) 375bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran return false; 376bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran } 377bec4a8e65d5af78b14adebcec3d9582dc229e6f2Jeykumar Sankaran } else { //A-family 378c5d8c2edd27f73d6d61db2e06c99597388c912b2Manoj Kumar AVM if(w_dscale > maxMDPDownscale || h_dscale > maxMDPDownscale) 37941269096daf2363b16dcd89627dd674529a26601Saurabh Shah return false; 38041269096daf2363b16dcd89627dd674529a26601Saurabh Shah } 38141269096daf2363b16dcd89627dd674529a26601Saurabh Shah } 38241269096daf2363b16dcd89627dd674529a26601Saurabh Shah 383df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran if((w_scale < 1.0f) || (h_scale < 1.0f)) { 384df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran const uint32_t upscale = 385df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran qdutils::MDPVersion::getInstance().getMaxMDPUpscale(); 386df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran const float w_uscale = 1.0f / w_scale; 387df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran const float h_uscale = 1.0f / h_scale; 388df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran 389df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran if(w_uscale > upscale || h_uscale > upscale) 390df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran return false; 391df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran } 392df991ce9e82b63e27859a4c534df4c6c9af2c915Jeykumar Sankaran 3930ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran return true; 3940ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran} 3950ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 3961a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shahovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type, 3971a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah int mixer) { 398c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran overlay::Overlay& ov = *ctx->mOverlay; 399c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran ovutils::eDest mdp_pipe = ovutils::OV_INVALID; 400c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 401c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran switch(type) { 402f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran case MDPCOMP_OV_DMA: 4031a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy, mixer); 404f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mdp_pipe != ovutils::OV_INVALID) { 405f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return mdp_pipe; 406f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 407f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran case MDPCOMP_OV_ANY: 408f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran case MDPCOMP_OV_RGB: 4091a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy, mixer); 410f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mdp_pipe != ovutils::OV_INVALID) { 411f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return mdp_pipe; 412f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 413c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 414f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(type == MDPCOMP_OV_RGB) { 415f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran //Requested only for RGB pipe 416f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran break; 417f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 418f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran case MDPCOMP_OV_VG: 4191a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy, mixer); 420f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran default: 421f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGE("%s: Invalid pipe type",__FUNCTION__); 422f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return ovutils::OV_INVALID; 423c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran }; 424c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return ovutils::OV_INVALID; 425c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 426c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 427f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranbool MDPComp::isFrameDoable(hwc_context_t *ctx) { 428af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah bool ret = true; 429f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran 430f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!isEnabled()) { 431f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); 432af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ret = false; 43356d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah } else if(qdutils::MDPVersion::getInstance().is8x26() && 434140ee6411106722dae886dc8c5b104b72d64dee0Ramkumar Radhakrishnan ctx->mVideoTransFlag && 435140ee6411106722dae886dc8c5b104b72d64dee0Ramkumar Radhakrishnan isSecondaryConnected(ctx)) { 43656d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah //1 Padding round to shift pipes across mixers 43756d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round", 43856d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah __FUNCTION__); 43956d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah ret = false; 440140ee6411106722dae886dc8c5b104b72d64dee0Ramkumar Radhakrishnan } else if(isSecondaryConfiguring(ctx)) { 441c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran ALOGD_IF( isDebug(),"%s: External Display connection is pending", 442f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__); 443af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ret = false; 444af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } else if(ctx->isPaddingRound) { 44503514577d0c705056352898f66ed2a8e9b131df8Raj Kamal ALOGD_IF(isDebug(), "%s: padding round invoked for dpy %d", 44603514577d0c705056352898f66ed2a8e9b131df8Raj Kamal __FUNCTION__,mDpy); 447af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ret = false; 448586aedccc2eaa76923bc22a3325fc2e4eff415e2Saurabh Shah } 449af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return ret; 450f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 451f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 452a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran/* 453a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran * 1) Identify layers that are not visible in the updating ROI and drop them 454a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran * from composition. 455a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran * 2) If we have a scaling layers which needs cropping against generated ROI. 456a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran * Reset ROI to full resolution. 457a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran */ 458bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaranbool MDPComp::validateAndApplyROI(hwc_context_t *ctx, 459bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran hwc_display_contents_1_t* list, hwc_rect_t roi) { 460bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int numAppLayers = ctx->listStats[mDpy].numAppLayers; 461bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 462bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!isValidRect(roi)) 463bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return false; 464bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 465a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran hwc_rect_t visibleRect = roi; 466a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran 467a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran for(int i = numAppLayers - 1; i >= 0; i--){ 468a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran 469a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran if(!isValidRect(visibleRect)) { 470a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran mCurrentFrame.drop[i] = true; 471a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran mCurrentFrame.dropCount++; 472f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran continue; 473a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran } 474a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran 475bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran const hwc_layer_1_t* layer = &list->hwLayers[i]; 476bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 477bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran hwc_rect_t dstRect = layer->displayFrame; 478f44bcdd642866a7763d09d568b0f91dd0949bc5bArun Kumar K.R hwc_rect_t srcRect = integerizeSourceCrop(layer->sourceCropf); 479bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 480a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran hwc_rect_t res = getIntersection(visibleRect, dstRect); 481bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 482bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int res_w = res.right - res.left; 483bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int res_h = res.bottom - res.top; 484bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int dst_w = dstRect.right - dstRect.left; 485bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int dst_h = dstRect.bottom - dstRect.top; 486bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 487bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!isValidRect(res)) { 488bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.drop[i] = true; 489bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.dropCount++; 490bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran }else { 491bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran /* Reset frame ROI when any layer which needs scaling also needs ROI 492bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran * cropping */ 493f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran if((res_w != dst_w || res_h != dst_h) && needsScaling (layer)) { 4940938709ed5efbf73eafbaed31bf069f4e9dfd427Arpita Banerjee ALOGI("%s: Resetting ROI due to scaling", __FUNCTION__); 495bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); 496bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.dropCount = 0; 497bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return false; 498bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 499a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran 500f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran /* deduct any opaque region from visibleRect */ 501f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran if (layer->blending == HWC_BLENDING_NONE) 502f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran visibleRect = deductRect(visibleRect, res); 503f74196ba20c5e3e9525cb10b6f51712e07ca107eJeykumar Sankaran } 504bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 505bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return true; 506bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran} 507bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 508bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaranvoid MDPComp::generateROI(hwc_context_t *ctx, hwc_display_contents_1_t* list) { 509bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int numAppLayers = ctx->listStats[mDpy].numAppLayers; 510bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 511bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!sEnablePartialFrameUpdate) { 512bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return; 513bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 514bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 515bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(mDpy || isDisplaySplit(ctx, mDpy)){ 516bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ALOGE_IF(isDebug(), "%s: ROI not supported for" 517bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran "the (1) external / virtual display's (2) dual DSI displays", 518bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran __FUNCTION__); 519bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return; 520bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 521bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 522a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran if(isSkipPresent(ctx, mDpy)) 523a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran return; 524a0179fa554ea9d26d74bdb55bb95796c08d76b44Jeykumar Sankaran 525bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(list->flags & HWC_GEOMETRY_CHANGED) 526bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return; 527bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 528bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran struct hwc_rect roi = (struct hwc_rect){0, 0, 0, 0}; 529bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran for(int index = 0; index < numAppLayers; index++ ) { 530bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if ((mCachedFrame.hnd[index] != list->hwLayers[index].handle) || 531bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran isYuvBuffer((private_handle_t *)list->hwLayers[index].handle)) { 532bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran hwc_rect_t dstRect = list->hwLayers[index].displayFrame; 533f44bcdd642866a7763d09d568b0f91dd0949bc5bArun Kumar K.R hwc_rect_t srcRect = integerizeSourceCrop( 534f44bcdd642866a7763d09d568b0f91dd0949bc5bArun Kumar K.R list->hwLayers[index].sourceCropf); 535bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 536bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran /* Intersect against display boundaries */ 537bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran roi = getUnion(roi, dstRect); 538bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 539bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 540bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 541bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!validateAndApplyROI(ctx, list, roi)){ 542bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran roi = (struct hwc_rect) {0, 0, 543bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran (int)ctx->dpyAttr[mDpy].xres, (int)ctx->dpyAttr[mDpy].yres}; 544bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 545bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 546bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ctx->listStats[mDpy].roi.x = roi.left; 547bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ctx->listStats[mDpy].roi.y = roi.top; 548bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ctx->listStats[mDpy].roi.w = roi.right - roi.left; 549bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ctx->listStats[mDpy].roi.h = roi.bottom - roi.top; 550bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 551bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: generated ROI: [%d, %d, %d, %d]", __FUNCTION__, 552bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran roi.left, roi.top, roi.right, roi.bottom); 553bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran} 554bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 555f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran/* Checks for conditions where all the layers marked for MDP comp cannot be 556f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran * bypassed. On such conditions we try to bypass atleast YUV layers */ 557c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahbool MDPComp::tryFullFrame(hwc_context_t *ctx, 558f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran hwc_display_contents_1_t* list){ 559f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 560af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah const int numAppLayers = ctx->listStats[mDpy].numAppLayers; 56169f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R int priDispW = ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres; 562f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 5631b28b60e15c27fee703a16fbd1e42e3b41b031fdRamkumar Radhakrishnan if(sIdleFallBack && !ctx->listStats[mDpy].secureUI) { 56433b155572be4b98d60a51d534247a4fb6f5ffad1Saurabh Shah ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy); 56533b155572be4b98d60a51d534247a4fb6f5ffad1Saurabh Shah return false; 56633b155572be4b98d60a51d534247a4fb6f5ffad1Saurabh Shah } 56733b155572be4b98d60a51d534247a4fb6f5ffad1Saurabh Shah 568f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(isSkipPresent(ctx, mDpy)) { 569af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ALOGD_IF(isDebug(),"%s: SKIP present: %d", 570af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah __FUNCTION__, 571af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah isSkipPresent(ctx, mDpy)); 572c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return false; 573c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 574c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 57569f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R if(mDpy > HWC_DISPLAY_PRIMARY && (priDispW > MAX_DISPLAY_DIM) && 57669f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R (ctx->dpyAttr[mDpy].xres < MAX_DISPLAY_DIM)) { 57769f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R // Disable MDP comp on Secondary when the primary is highres panel and 57869f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R // the secondary is a normal 1080p, because, MDP comp on secondary under 57969f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R // in such usecase, decimation gets used for downscale and there will be 58069f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R // a quality mismatch when there will be a fallback to GPU comp 58169f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R ALOGD_IF(isDebug(), "%s: Disable MDP Compositon for Secondary Disp", 58269f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R __FUNCTION__); 58369f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R return false; 58469f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R } 58569f90bdd131ca3c1daef99872aaf435fc2ef6e95Arun Kumar K.R 586ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan // check for action safe flag and downscale mode which requires scaling. 587ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan if(ctx->dpyAttr[mDpy].mActionSafePresent 588ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan || ctx->dpyAttr[mDpy].mDownScaleMode) { 589ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan ALOGD_IF(isDebug(), "%s: Scaling needed for this frame",__FUNCTION__); 590ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan return false; 591ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan } 592ba3d6165c19bcec9a56eb2db1b13f8f930c5651bRamkumar Radhakrishnan 593c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran for(int i = 0; i < numAppLayers; ++i) { 594c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[i]; 595c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran private_handle_t *hnd = (private_handle_t *)layer->handle; 596f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran 597efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(isYuvBuffer(hnd) && has90Transform(layer)) { 598efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(!canUseRotator(ctx, mDpy)) { 599efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(), "%s: Can't use rotator for dpy %d", 600efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah __FUNCTION__, mDpy); 60186adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar return false; 60286adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar } 603c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 6042902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula 6052902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp 6062902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula // may not need it if Gfx pre-rotation can handle all flips & rotations 6072902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula if(qdutils::MDPVersion::getInstance().is8x26() && 6082902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula (ctx->dpyAttr[mDpy].xres > 1024) && 6092902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula (layer->transform & HWC_TRANSFORM_FLIP_H) && 6102902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula (!isYuvBuffer(hnd))) 6112902acdce6ec5278db2d207dc467acb122423d6cPrabhanjan Kandula return false; 612c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 613af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 614f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah if(ctx->mAD->isDoable()) { 615f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah return false; 616f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah } 617f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah 618af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah //If all above hard conditions are met we can do full or partial MDP comp. 619af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah bool ret = false; 620af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah if(fullMDPComp(ctx, list)) { 621af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ret = true; 622e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran } else if(partialMDPComp(ctx, list)) { 623af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ret = true; 624af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 62586c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula 626af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return ret; 627af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 628af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 629af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahbool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { 630efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah //Will benefit presentation / secondary-only layer. 631efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if((mDpy > HWC_DISPLAY_PRIMARY) && 632efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah (list->numHwLayers - 1) > MAX_SEC_LAYERS) { 633efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); 634efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 635efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 636efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 637efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah const int numAppLayers = ctx->listStats[mDpy].numAppLayers; 638efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah for(int i = 0; i < numAppLayers; i++) { 639efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah hwc_layer_1_t* layer = &list->hwLayers[i]; 640efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(not isSupportedForMDPComp(ctx, layer)) { 641efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(), "%s: Unsupported layer in list",__FUNCTION__); 642efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 643efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 64484a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu 64584a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu //For 8x26, if there is only one layer which needs scale for secondary 64684a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu //while no scale for primary display, DMA pipe is occupied by primary. 64784a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu //If need to fall back to GLES composition, virtual display lacks DMA 64884a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu //pipe and error is reported. 64984a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu if(qdutils::MDPVersion::getInstance().is8x26() && 65084a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu mDpy >= HWC_DISPLAY_EXTERNAL && 65186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula qhwc::needsScaling(layer)) 65284a958f6e82e8817c4a868b7e1d7c044ebbd8e74Yang Xu return false; 653efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 654c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 655af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.fbCount = 0; 656bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran memcpy(&mCurrentFrame.isFBComposed, &mCurrentFrame.drop, 657bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran sizeof(mCurrentFrame.isFBComposed)); 658bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount - 659bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.dropCount; 660af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 66115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(sEnable4k2kYUVSplit){ 662f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah adjustForSourceSplit(ctx, list); 66315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 66415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 665c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!postHeuristicsHandling(ctx, list)) { 666c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF(isDebug(), "post heuristic handling failed"); 667c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 6688eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah return false; 6698eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah } 6708eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah 671af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return true; 672af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 673af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 674af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shahbool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) 675af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah{ 676e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran if(!sEnableMixedMode) { 677e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran //Mixed mode is disabled. No need to even try caching. 678e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran return false; 679e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran } 680e5a8bbcdfedda1658779baa80bc8f067505097caJeykumar Sankaran 68194f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah bool ret = false; 682116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah if(list->flags & HWC_GEOMETRY_CHANGED) { //Try load based first 683dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ret = loadBasedComp(ctx, list) or 684116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah cacheBasedComp(ctx, list); 685116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah } else { 686116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah ret = cacheBasedComp(ctx, list) or 687dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah loadBasedComp(ctx, list); 68894f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 68994f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah 69094f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah return ret; 69194f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah} 69294f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah 69394f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shahbool MDPComp::cacheBasedComp(hwc_context_t *ctx, 69494f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah hwc_display_contents_1_t* list) { 69594f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah int numAppLayers = ctx->listStats[mDpy].numAppLayers; 696af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.reset(numAppLayers); 697af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah updateLayerCache(ctx, list); 698efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 699efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah //If an MDP marked layer is unsupported cannot do partial MDP Comp 700efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah for(int i = 0; i < numAppLayers; i++) { 701efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(!mCurrentFrame.isFBComposed[i]) { 702efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah hwc_layer_1_t* layer = &list->hwLayers[i]; 703efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(not isSupportedForMDPComp(ctx, layer)) { 704efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(), "%s: Unsupported layer in list", 705efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah __FUNCTION__); 706c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 707efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 708efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 709efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 710efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 711efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 71211bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah updateYUV(ctx, list, false /*secure only*/); 71336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula bool ret = markLayersForCaching(ctx, list); //sets up fbZ also 714efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if(!ret) { 715efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(),"%s: batching failed, dpy %d",__FUNCTION__, mDpy); 716c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 717efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 718efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 719af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 720af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah int mdpCount = mCurrentFrame.mdpCount; 721efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 72215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(sEnable4k2kYUVSplit){ 723f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah adjustForSourceSplit(ctx, list); 72415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 72515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 726efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah //Will benefit cases where a video has non-updating background. 727efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah if((mDpy > HWC_DISPLAY_PRIMARY) and 728efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah (mdpCount > MAX_SEC_LAYERS)) { 729efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah ALOGD_IF(isDebug(), "%s: Exceeds max secondary pipes",__FUNCTION__); 730c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 731efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return false; 732efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 733efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 734c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!postHeuristicsHandling(ctx, list)) { 735c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF(isDebug(), "post heuristic handling failed"); 736c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 7378eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah return false; 7388eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah } 7398eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah 740af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return true; 741af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 742af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 743dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shahbool MDPComp::loadBasedComp(hwc_context_t *ctx, 74494f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah hwc_display_contents_1_t* list) { 745404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R if(not isLoadBasedCompDoable(ctx)) { 746116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah return false; 747116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah } 748116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah 749dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah const int numAppLayers = ctx->listStats[mDpy].numAppLayers; 750dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah const int numNonDroppedLayers = numAppLayers - mCurrentFrame.dropCount; 751dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah const int stagesForMDP = min(sMaxPipesPerMixer, 752dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ctx->mOverlay->availablePipes(mDpy, Overlay::MIXER_DEFAULT)); 753dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah 754dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah int mdpBatchSize = stagesForMDP - 1; //1 stage for FB 755dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah int fbBatchSize = numNonDroppedLayers - mdpBatchSize; 756dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah int lastMDPSupportedIndex = numAppLayers; 757dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah int dropCount = 0; 758dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah 759dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //Find the minimum MDP batch size 760dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah for(int i = 0; i < numAppLayers;i++) { 761dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah if(mCurrentFrame.drop[i]) { 762dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah dropCount++; 763e4ce4d8657dc2e8fd70600b0dc1010aa798c7305Jeykumar Sankaran continue; 76494f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 765dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah hwc_layer_1_t* layer = &list->hwLayers[i]; 766dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah if(not isSupportedForMDPComp(ctx, layer)) { 767dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah lastMDPSupportedIndex = i; 768dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mdpBatchSize = min(i - dropCount, stagesForMDP - 1); 769dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah fbBatchSize = numNonDroppedLayers - mdpBatchSize; 770dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah break; 77194f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 77294f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 77394f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah 774dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ALOGD_IF(isDebug(), "%s:Before optimizing fbBatch, mdpbatch %d, fbbatch %d " 775dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah "dropped %d", __FUNCTION__, mdpBatchSize, fbBatchSize, 776dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mCurrentFrame.dropCount); 77715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 778dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //Start at a point where the fb batch should at least have 2 layers, for 779dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //this mode to be justified. 780dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah while(fbBatchSize < 2) { 781dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ++fbBatchSize; 782dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah --mdpBatchSize; 78394f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 78494f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah 785dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //If there are no layers for MDP, this mode doesnt make sense. 786dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah if(mdpBatchSize < 1) { 787dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ALOGD_IF(isDebug(), "%s: No MDP layers after optimizing for fbBatch", 788dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah __FUNCTION__); 789116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah return false; 790116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah } 791116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah 792116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah mCurrentFrame.reset(numAppLayers); 793116df906200ccbdd0933d2cabc8ac8f0d65fa1baSaurabh Shah 794dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //Try with successively smaller mdp batch sizes until we succeed or reach 1 795dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah while(mdpBatchSize > 0) { 796dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah //Mark layers for MDP comp 797dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah int mdpBatchLeft = mdpBatchSize; 798dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah for(int i = 0; i < lastMDPSupportedIndex and mdpBatchLeft; i++) { 799dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah if(mCurrentFrame.drop[i]) { 800dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah continue; 801e4ce4d8657dc2e8fd70600b0dc1010aa798c7305Jeykumar Sankaran } 802e4ce4d8657dc2e8fd70600b0dc1010aa798c7305Jeykumar Sankaran mCurrentFrame.isFBComposed[i] = false; 803dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah --mdpBatchLeft; 80495a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah } 80595a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah 806dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mCurrentFrame.fbZ = mdpBatchSize; 807dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mCurrentFrame.fbCount = fbBatchSize; 808dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mCurrentFrame.mdpCount = mdpBatchSize; 80995a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah 810dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ALOGD_IF(isDebug(), "%s:Trying with: mdpbatch %d fbbatch %d dropped %d", 811dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah __FUNCTION__, mdpBatchSize, fbBatchSize, 812dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah mCurrentFrame.dropCount); 813c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 814dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah if(postHeuristicsHandling(ctx, list)) { 815dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ALOGD_IF(isDebug(), "%s: Postheuristics handling succeeded", 816dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah __FUNCTION__); 817dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah return true; 818dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah } 81915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 820c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 821dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah --mdpBatchSize; 822dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah ++fbBatchSize; 82395a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah } 82495a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah 825dfe40345210611d4548daa7ba1fc032fac238e97Saurabh Shah return false; 82695a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah} 82795a0158274f4239439e0dde307994a53fb12a8b5Saurabh Shah 828404047f2c61687024048b04374ea736285ddded1Arun Kumar K.Rbool MDPComp::isLoadBasedCompDoable(hwc_context_t *ctx) { 8297cd2a020040a3e81fdd88c376169fd78b5417efdPrabhanjan Kandula if(mDpy or isSecurePresent(ctx, mDpy) or 8307cd2a020040a3e81fdd88c376169fd78b5417efdPrabhanjan Kandula isYuvPresent(ctx, mDpy)) { 83194f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah return false; 83294f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah } 83394f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah return true; 83494f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah} 83594f50bebdee0b3ab9deb6d51426c542407ced5fdSaurabh Shah 836c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahbool MDPComp::tryVideoOnly(hwc_context_t *ctx, 837c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah hwc_display_contents_1_t* list) { 838c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah const bool secureOnly = true; 839c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah return videoOnlyComp(ctx, list, not secureOnly) or 840c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah videoOnlyComp(ctx, list, secureOnly); 841c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah} 842c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 843c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahbool MDPComp::videoOnlyComp(hwc_context_t *ctx, 84411bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah hwc_display_contents_1_t* list, bool secureOnly) { 845af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah int numAppLayers = ctx->listStats[mDpy].numAppLayers; 846bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 847af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.reset(numAppLayers); 84822f45504c700b0011b418791c461939c90c34df6Jeykumar Sankaran mCurrentFrame.fbCount -= mCurrentFrame.dropCount; 84911bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah updateYUV(ctx, list, secureOnly); 85041269096daf2363b16dcd89627dd674529a26601Saurabh Shah int mdpCount = mCurrentFrame.mdpCount; 851af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 852c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!isYuvPresent(ctx, mDpy) or (mdpCount == 0)) { 853c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 854af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return false; 855af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 856af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 85711c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran /* Bail out if we are processing only secured video layers 85811c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran * and we dont have any */ 85911c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran if(!isSecurePresent(ctx, mDpy) && secureOnly){ 860c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 86111c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran return false; 86211c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran } 86311c3d6d70c9b3e1f9a9245573d682d009fe05744Jeykumar Sankaran 864c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(mCurrentFrame.fbCount) 865c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.fbZ = mCurrentFrame.mdpCount; 86641269096daf2363b16dcd89627dd674529a26601Saurabh Shah 867c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(sEnable4k2kYUVSplit){ 868c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah adjustForSourceSplit(ctx, list); 869c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah } 870c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 871c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!postHeuristicsHandling(ctx, list)) { 872c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF(isDebug(), "post heuristic handling failed"); 873c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 8748eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah return false; 8758eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah } 8768eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah 877c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return true; 878c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 879c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 880f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran/* Checks for conditions where YUV layers cannot be bypassed */ 881f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranbool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { 882c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan if(isSkipLayer(layer)) { 883e188278e86ebb2f7f1ed3762855f15062b7f9d03Saurabh Shah ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy); 884f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 885c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 886c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 88786adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar if(layer->transform & HWC_TRANSFORM_ROT_90 && !canUseRotator(ctx,mDpy)) { 88886adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar ALOGD_IF(isDebug(), "%s: no free DMA pipe",__FUNCTION__); 88986adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar return false; 89086adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar } 89186adeda0140053bfc618f5fc087d30c7221459daAmara Venkata Mastan Manoj Kumar 892f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(isSecuring(ctx, layer)) { 893f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); 894f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 895f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 896f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 89741269096daf2363b16dcd89627dd674529a26601Saurabh Shah if(!isValidDimension(ctx, layer)) { 89841269096daf2363b16dcd89627dd674529a26601Saurabh Shah ALOGD_IF(isDebug(), "%s: Buffer is of invalid width", 89941269096daf2363b16dcd89627dd674529a26601Saurabh Shah __FUNCTION__); 90041269096daf2363b16dcd89627dd674529a26601Saurabh Shah return false; 901c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 90241269096daf2363b16dcd89627dd674529a26601Saurabh Shah 903a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed if(layer->planeAlpha < 0xFF) { 904a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed ALOGD_IF(isDebug(), "%s: Cannot handle YUV layer with plane alpha\ 905a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed in video only mode", 906a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed __FUNCTION__); 907a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed return false; 908a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed } 909a8a36dd4c76206acaa0c2a2a9647965c294308c5Naseer Ahmed 910c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return true; 911c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 912c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 91336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula/* starts at fromIndex and check for each layer to find 91436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * if it it has overlapping with any Updating layer above it in zorder 91536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * till the end of the batch. returns true if it finds any intersection */ 91636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandulabool MDPComp::canPushBatchToTop(const hwc_display_contents_1_t* list, 91736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int fromIndex, int toIndex) { 91836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula for(int i = fromIndex; i < toIndex; i++) { 91936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { 92036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(intersectingUpdatingLayers(list, i+1, toIndex, i)) { 92136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula return false; 92236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 92336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 92436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 92536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula return true; 92636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula} 92736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula 92836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula/* Checks if given layer at targetLayerIndex has any 92936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * intersection with all the updating layers in beween 93036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * fromIndex and toIndex. Returns true if it finds intersectiion */ 93136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandulabool MDPComp::intersectingUpdatingLayers(const hwc_display_contents_1_t* list, 93236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int fromIndex, int toIndex, int targetLayerIndex) { 93336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula for(int i = fromIndex; i <= toIndex; i++) { 93436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(!mCurrentFrame.isFBComposed[i]) { 93536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(areLayersIntersecting(&list->hwLayers[i], 93636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula &list->hwLayers[targetLayerIndex])) { 93736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula return true; 93836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 93936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 94036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 94136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula return false; 94236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula} 94336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula 94436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandulaint MDPComp::getBatch(hwc_display_contents_1_t* list, 94536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int& maxBatchStart, int& maxBatchEnd, 94636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int& maxBatchCount) { 94736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int i = 0; 94836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int fbZOrder =-1; 949eeeb8334059a63fe95f8a7db276d358bb2ddb857Jeykumar Sankaran int droppedLayerCt = 0; 95036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula while (i < mCurrentFrame.layerCount) { 95136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int batchCount = 0; 95236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int batchStart = i; 95336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int batchEnd = i; 954eeeb8334059a63fe95f8a7db276d358bb2ddb857Jeykumar Sankaran /* Adjust batch Z order with the dropped layers so far */ 955eeeb8334059a63fe95f8a7db276d358bb2ddb857Jeykumar Sankaran int fbZ = batchStart - droppedLayerCt; 95636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int firstZReverseIndex = -1; 95785cc9b8dfc7a50f6e8083b67056f3a25702fbba1Prabhanjan Kandula int updatingLayersAbove = 0;//Updating layer count in middle of batch 95836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula while(i < mCurrentFrame.layerCount) { 95936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(!mCurrentFrame.isFBComposed[i]) { 96036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(!batchCount) { 96136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 96236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula break; 96336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 96436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula updatingLayersAbove++; 96536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 96636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula continue; 96736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } else { 96836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(mCurrentFrame.drop[i]) { 96936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 970eeeb8334059a63fe95f8a7db276d358bb2ddb857Jeykumar Sankaran droppedLayerCt++; 97136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula continue; 97236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } else if(updatingLayersAbove <= 0) { 97336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchCount++; 97436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchEnd = i; 97536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 97636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula continue; 97736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } else { //Layer is FBComposed, not a drop & updatingLayer > 0 97836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula 97936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula // We have a valid updating layer already. If layer-i not 98036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula // have overlapping with all updating layers in between 98136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula // batch-start and i, then we can add layer i to batch. 98236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(!intersectingUpdatingLayers(list, batchStart, i-1, i)) { 98336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchCount++; 98436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchEnd = i; 98536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 98636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula continue; 98736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } else if(canPushBatchToTop(list, batchStart, i)) { 98836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //If All the non-updating layers with in this batch 98936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //does not have intersection with the updating layers 99036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //above in z-order, then we can safely move the batch to 99136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //higher z-order. Increment fbZ as it is moving up. 99236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if( firstZReverseIndex < 0) { 99336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula firstZReverseIndex = i; 99436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 99536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchCount++; 99636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula batchEnd = i; 99736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula fbZ += updatingLayersAbove; 99836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i++; 99936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula updatingLayersAbove = 0; 100036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula continue; 100136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } else { 100236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //both failed.start the loop again from here. 100336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(firstZReverseIndex >= 0) { 100436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula i = firstZReverseIndex; 100536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 100636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula break; 100736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 100836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 100936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 101036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 101136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(batchCount > maxBatchCount) { 101236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula maxBatchCount = batchCount; 101336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula maxBatchStart = batchStart; 101436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula maxBatchEnd = batchEnd; 101536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula fbZOrder = fbZ; 101636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 101736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 101836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula return fbZOrder; 101936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula} 102036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula 102136035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandulabool MDPComp::markLayersForCaching(hwc_context_t* ctx, 102236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula hwc_display_contents_1_t* list) { 102336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula /* Idea is to keep as many non-updating(cached) layers in FB and 102436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * send rest of them through MDP. This is done in 2 steps. 102536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * 1. Find the maximum contiguous batch of non-updating layers. 102636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * 2. See if we can improve this batch size for caching by adding 102736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * opaque layers around the batch, if they don't have 102836035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * any overlapping with the updating layers in between. 102936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * NEVER mark an updating layer for caching. 103036035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula * But cached ones can be marked for MDP */ 1031f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1032f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int maxBatchStart = -1; 1033bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran int maxBatchEnd = -1; 1034f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int maxBatchCount = 0; 103536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula int fbZ = -1; 1036f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 10372b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah /* Nothing is cached. No batching needed */ 10382b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah if(mCurrentFrame.fbCount == 0) { 1039efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return true; 1040af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 10412b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah 10422b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah /* No MDP comp layers, try to use other comp modes */ 10432b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah if(mCurrentFrame.mdpCount == 0) { 10442b59168391f5d3fb025ccae8d936d5b09bddb162Saurabh Shah return false; 1045af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 1046f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 104736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula fbZ = getBatch(list, maxBatchStart, maxBatchEnd, maxBatchCount); 1048bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran 104936035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula /* reset rest of the layers lying inside ROI for MDP comp */ 1050f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int i = 0; i < mCurrentFrame.layerCount; i++) { 1051efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah hwc_layer_1_t* layer = &list->hwLayers[i]; 1052bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if((i < maxBatchStart || i > maxBatchEnd) && 105336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula mCurrentFrame.isFBComposed[i]){ 1054bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!mCurrentFrame.drop[i]){ 1055bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran //If an unsupported layer is being attempted to 1056bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran //be pulled out we should fail 1057bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(not isSupportedForMDPComp(ctx, layer)) { 1058bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran return false; 1059bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran } 1060bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.isFBComposed[i] = false; 1061efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah } 1062f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1063f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1064f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 106536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula // update the frame data 106636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula mCurrentFrame.fbZ = fbZ; 106736035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula mCurrentFrame.fbCount = maxBatchCount; 1068af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.mdpCount = mCurrentFrame.layerCount - 1069bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.fbCount - mCurrentFrame.dropCount; 1070f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1071f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, 107236035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula mCurrentFrame.fbCount); 1073efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 1074efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah return true; 1075f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 107611154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah 1077f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranvoid MDPComp::updateLayerCache(hwc_context_t* ctx, 1078efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah hwc_display_contents_1_t* list) { 1079f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int numAppLayers = ctx->listStats[mDpy].numAppLayers; 1080efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah int fbCount = 0; 1081f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1082f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int i = 0; i < numAppLayers; i++) { 1083f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { 1084bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran if(!mCurrentFrame.drop[i]) 1085bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran fbCount++; 1086f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.isFBComposed[i] = true; 1087f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } else { 1088af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.isFBComposed[i] = false; 1089f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1090c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 1091af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 1092efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah mCurrentFrame.fbCount = fbCount; 1093bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount 1094bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran - mCurrentFrame.dropCount; 1095efab1d5273ce9a284e306f2607e501410cfbc8b9Saurabh Shah 1096bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: MDP count: %d FB count %d drop count: %d" 1097bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ,__FUNCTION__, mCurrentFrame.mdpCount, mCurrentFrame.fbCount, 1098bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.dropCount); 1099f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 1100c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 110111bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shahvoid MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list, 110211bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah bool secureOnly) { 1103f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int nYuvCount = ctx->listStats[mDpy].yuvCount; 1104f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int index = 0;index < nYuvCount; index++){ 1105f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; 1106f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; 1107f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1108f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!isYUVDoable(ctx, layer)) { 1109f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!mCurrentFrame.isFBComposed[nYuvIndex]) { 1110f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.isFBComposed[nYuvIndex] = true; 1111f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.fbCount++; 1112f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1113c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } else { 1114f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mCurrentFrame.isFBComposed[nYuvIndex]) { 111511bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 111611bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah if(!secureOnly || isSecureBuffer(hnd)) { 111711bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah mCurrentFrame.isFBComposed[nYuvIndex] = false; 111811bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah mCurrentFrame.fbCount--; 111911bf9c368a2ff832b1a20d9c90ec796e3d29bf9fSaurabh Shah } 1120f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1121c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 1122f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1123af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah 1124af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah mCurrentFrame.mdpCount = mCurrentFrame.layerCount - 1125bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran mCurrentFrame.fbCount - mCurrentFrame.dropCount; 1126bc037e0bbb3d1778fb4bde55582fd1d4e666f957Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: fb count: %d",__FUNCTION__, 1127f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mCurrentFrame.fbCount); 1128f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran} 1129f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 11303d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusuhwc_rect_t MDPComp::getUpdatingFBRect(hwc_display_contents_1_t* list){ 1131d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran hwc_rect_t fbRect = (struct hwc_rect){0, 0, 0, 0}; 1132d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran 1133d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran /* Update only the region of FB needed for composition */ 1134d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran for(int i = 0; i < mCurrentFrame.layerCount; i++ ) { 1135d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran if(mCurrentFrame.isFBComposed[i] && !mCurrentFrame.drop[i]) { 1136d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[i]; 1137d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran hwc_rect_t dst = layer->displayFrame; 1138d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran fbRect = getUnion(fbRect, dst); 1139d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran } 1140d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran } 1141d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran return fbRect; 1142d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran} 1143d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran 1144c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shahbool MDPComp::postHeuristicsHandling(hwc_context_t *ctx, 1145c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah hwc_display_contents_1_t* list) { 1146c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1147c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah //Capability checks 11483d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu if(!resourceCheck()) { 1149c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF(isDebug(), "%s: resource check failed", __FUNCTION__); 1150c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah return false; 1151c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah } 1152c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1153c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah //Limitations checks 1154c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(!hwLimitationsCheck(ctx, list)) { 1155c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF(isDebug(), "%s: HW limitations",__FUNCTION__); 1156c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah return false; 1157c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah } 1158c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1159f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah //Configure framebuffer first if applicable 1160f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah if(mCurrentFrame.fbZ >= 0) { 11613d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu hwc_rect_t fbRect = getUpdatingFBRect(list); 1162d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran if(!ctx->mFBUpdate[mDpy]->prepare(ctx, list, fbRect, mCurrentFrame.fbZ)) 1163d5d41f238fd48170a0755bde427088c92ca0920cJeykumar Sankaran { 1164f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah ALOGD_IF(isDebug(), "%s configure framebuffer failed", 1165f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah __FUNCTION__); 1166f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah return false; 1167f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 1168f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 1169f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah 1170c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.map(); 1171c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1172f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!allocLayerPipes(ctx, list)) { 1173f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); 1174af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return false; 1175f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1176f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1177f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; 1178af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah index++) { 1179f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!mCurrentFrame.isFBComposed[index]) { 1180f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int mdpIndex = mCurrentFrame.layerToMDP[index]; 1181f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[index]; 1182f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 118336035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula //Leave fbZ for framebuffer. CACHE/GLES layers go here. 118436035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula if(mdpNextZOrder == mCurrentFrame.fbZ) { 118536035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula mdpNextZOrder++; 118636035afc0c366c26d7c330d004e7ded510c1f88cPrabhanjan Kandula } 1187f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; 1188f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran cur_pipe->zOrder = mdpNextZOrder++; 1189f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 119015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna private_handle_t *hnd = (private_handle_t *)layer->handle; 119115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ 119215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(configure4k2kYuv(ctx, layer, 119315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna mCurrentFrame.mdpToLayer[mdpIndex]) 119415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna != 0 ){ 119515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(), "%s: Failed to configure split pipes \ 119615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna for layer %d",__FUNCTION__, index); 119715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 119815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 119915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna else{ 120015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna mdpNextZOrder++; 120115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 120215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna continue; 120315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1204f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ 1205f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ 120615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna layer %d",__FUNCTION__, index); 1207af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return false; 1208f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1209af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah } 1210f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 1211f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 12121029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah if(!ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd)) { 12131029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah ALOGD_IF(isDebug(), "%s: Failed to validate and set overlay for dpy %d" 12141029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah ,__FUNCTION__, mDpy); 12151029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah return false; 12161029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah } 12171029ad2b12d5f30e77b2c2f85da891f2d1842424Saurabh Shah 1218c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah setRedraw(ctx, list); 1219af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah return true; 1220af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah} 1221f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 12223d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusubool MDPComp::resourceCheck() { 122302e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah const bool fbUsed = mCurrentFrame.fbCount; 122402e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah if(mCurrentFrame.mdpCount > sMaxPipesPerMixer - fbUsed) { 122502e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); 122602e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah return false; 122702e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah } 122802e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah return true; 122902e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah} 123002e299800013a8758daa9ed58a3fba1199bb32daSaurabh Shah 123186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandulabool MDPComp::hwLimitationsCheck(hwc_context_t* ctx, 123286c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula hwc_display_contents_1_t* list) { 123386c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula 123486c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //A-family hw limitation: 123586c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //If a layer need alpha scaling, MDP can not support. 123686c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(ctx->mMDP.version < qdutils::MDSS_V5) { 123786c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula for(int i = 0; i < mCurrentFrame.layerCount; ++i) { 123886c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(!mCurrentFrame.isFBComposed[i] && 123986c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula isAlphaScaled( &list->hwLayers[i])) { 124086c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula ALOGD_IF(isDebug(), "%s:frame needs alphaScaling",__FUNCTION__); 124186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula return false; 124286c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 124386c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 124486c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 124586c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula 124686c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula // On 8x26 & 8974 hw, we have a limitation of downscaling+blending. 124786c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //If multiple layers requires downscaling and also they are overlapping 124886c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //fall back to GPU since MDSS can not handle it. 124986c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(qdutils::MDPVersion::getInstance().is8x74v2() || 125086c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula qdutils::MDPVersion::getInstance().is8x26()) { 125186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula for(int i = 0; i < mCurrentFrame.layerCount-1; ++i) { 125286c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula hwc_layer_1_t* botLayer = &list->hwLayers[i]; 125386c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(!mCurrentFrame.isFBComposed[i] && 125486c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula isDownscaleRequired(botLayer)) { 125586c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //if layer-i is marked for MDP and needs downscaling 125686c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula //check if any MDP layer on top of i & overlaps with layer-i 125786c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula for(int j = i+1; j < mCurrentFrame.layerCount; ++j) { 125886c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula hwc_layer_1_t* topLayer = &list->hwLayers[j]; 125986c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(!mCurrentFrame.isFBComposed[j] && 126086c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula isDownscaleRequired(topLayer)) { 126186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula hwc_rect_t r = getIntersection(botLayer->displayFrame, 126286c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula topLayer->displayFrame); 126386c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula if(isValidRect(r)) 126486c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula return false; 126586c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 126686c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 126786c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 126886c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 126986c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } 127086c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula return true; 127186c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula} 127286c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula 1273f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaranint MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) { 12748eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah int ret = 0; 1275af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah const int numLayers = ctx->listStats[mDpy].numAppLayers; 1276b68089410e6856f272c70cc9dbe652e336c82006Ramkumar Radhakrishnan 127703514577d0c705056352898f66ed2a8e9b131df8Raj Kamal //Do not cache the information for next draw cycle. 127803514577d0c705056352898f66ed2a8e9b131df8Raj Kamal if(numLayers > MAX_NUM_APP_LAYERS or (!numLayers)) { 127903514577d0c705056352898f66ed2a8e9b131df8Raj Kamal ALOGI("%s: Unsupported layer count for mdp composition", 128003514577d0c705056352898f66ed2a8e9b131df8Raj Kamal __FUNCTION__); 1281c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCachedFrame.reset(); 1282c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah return -1; 12831a050829890735bc5a936ad65bf9cad80295306bSaurabh Shah } 128489235b6c563e68046aed07d86746d747f48eca67Prabhanjan Kandula 1285c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah //reset old data 1286c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.reset(numLayers); 1287c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); 1288c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.dropCount = 0; 1289c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1290c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan // Detect the start of animation and fall back to GPU only once to cache 1291c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan // all the layers in FB and display FB content untill animation completes. 1292c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan if(ctx->listStats[mDpy].isDisplayAnimating) { 1293c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan mCurrentFrame.needsRedraw = false; 1294c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan if(ctx->mAnimationState[mDpy] == ANIMATION_STOPPED) { 1295c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan mCurrentFrame.needsRedraw = true; 1296c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan ctx->mAnimationState[mDpy] = ANIMATION_STARTED; 1297c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan } 1298c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan setMDPCompLayerFlags(ctx, list); 1299c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan mCachedFrame.updateCounts(mCurrentFrame); 1300c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan ret = -1; 1301c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan return ret; 1302c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan } else { 1303c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan ctx->mAnimationState[mDpy] = ANIMATION_STOPPED; 1304c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan } 1305c3da4cc59d8e21b5905bd0ee3adf556dfe62b0e1Ramkumar Radhakrishnan 13061a050829890735bc5a936ad65bf9cad80295306bSaurabh Shah //Hard conditions, if not met, cannot do MDP comp 1307c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(isFrameDoable(ctx)) { 1308c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah generateROI(ctx, list); 1309c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah 1310c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah if(tryFullFrame(ctx, list) || tryVideoOnly(ctx, list)) { 1311c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah setMDPCompLayerFlags(ctx, list); 1312c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah } else { 1313c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah reset(ctx); 1314c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop)); 1315c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCurrentFrame.dropCount = 0; 13168eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah ret = -1; 1317f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 13181a050829890735bc5a936ad65bf9cad80295306bSaurabh Shah } else { 1319c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", 1320c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah __FUNCTION__); 13218eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah ret = -1; 13221a050829890735bc5a936ad65bf9cad80295306bSaurabh Shah } 1323f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1324f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(isDebug()) { 1325c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD("GEOMETRY change: %d", 1326c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah (list->flags & HWC_GEOMETRY_CHANGED)); 1327f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran android::String8 sDump(""); 1328f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran dump(sDump); 1329c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah ALOGD("%s",sDump.string()); 1330c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 1331c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1332c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCachedFrame.cacheAll(list); 1333c477a410de65e8b662c0e9d7642afb538d0430eaSaurabh Shah mCachedFrame.updateCounts(mCurrentFrame); 13348eeb53efa1e615545f646a14ae2e8157e0a9bae6Saurabh Shah return ret; 1335c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 1336c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1337404047f2c61687024048b04374ea736285ddded1Arun Kumar K.Rbool MDPComp::allocSplitVGPipesfor4k2k(hwc_context_t *ctx, int index) { 133815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 133915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna bool bRet = true; 134015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int mdpIndex = mCurrentFrame.layerToMDP[index]; 134115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; 134215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna info.pipeInfo = new MdpYUVPipeInfo; 134315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna info.rot = NULL; 134415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpYUVPipeInfo& pipe_info = *(MdpYUVPipeInfo*)info.pipeInfo; 134515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ePipeType type = MDPCOMP_OV_VG; 134615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 134715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna pipe_info.lIndex = ovutils::OV_INVALID; 134815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna pipe_info.rIndex = ovutils::OV_INVALID; 134915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 135015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); 135115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(pipe_info.lIndex == ovutils::OV_INVALID){ 135215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna bRet = false; 135315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: allocating first VG pipe failed", 135415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__); 135515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 135615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); 135715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(pipe_info.rIndex == ovutils::OV_INVALID){ 135815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna bRet = false; 135915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: allocating second VG pipe failed", 136015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__); 136115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 136215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return bRet; 136315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna} 1364404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R//=============MDPCompNonSplit================================================== 1365c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1366f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shahvoid MDPCompNonSplit::adjustForSourceSplit(hwc_context_t *ctx, 1367404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R hwc_display_contents_1_t*) { 136815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //As we split 4kx2k yuv layer and program to 2 VG pipes 136915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //(if available) increase mdpcount accordingly 137015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna mCurrentFrame.mdpCount += ctx->listStats[mDpy].yuv4k2kCount; 1371f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah 1372f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah //If 4k2k Yuv layer split is possible, and if 1373f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah //fbz is above 4k2k layer, increment fb zorder by 1 1374f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah //as we split 4k2k layer and increment zorder for right half 1375f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah //of the layer 1376f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah if(mCurrentFrame.fbZ >= 0) { 1377f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah int n4k2kYuvCount = ctx->listStats[mDpy].yuv4k2kCount; 1378f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah for(int index = 0; index < n4k2kYuvCount; index++){ 1379f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah int n4k2kYuvIndex = 1380f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah ctx->listStats[mDpy].yuv4k2kIndices[index]; 1381b64922f99edce921000e0aaf17bd3bcb686910d1Dileep Kumar Reddi if(mCurrentFrame.fbZ >= n4k2kYuvIndex){ 1382f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah mCurrentFrame.fbZ += 1; 1383f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 1384f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 1385f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 138615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna} 138715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 1388c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed/* 1389c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed * Configures pipe(s) for MDP composition 1390c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed */ 1391f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahint MDPCompNonSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, 1392f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran PipeLayerPair& PipeLayerPair) { 1393f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah MdpPipeInfoNonSplit& mdp_info = 1394f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah *(static_cast<MdpPipeInfoNonSplit*>(PipeLayerPair.pipeInfo)); 1395327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; 1396327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); 1397327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eIsFg isFg = IS_FG_OFF; 1398327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eDest dest = mdp_info.index; 1399327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 1400f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", 1401f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__, layer, zOrder, dest); 1402f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1403f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return configureNonSplit(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, 1404f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran &PipeLayerPair.rot); 1405c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 1406c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1407f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool MDPCompNonSplit::allocLayerPipes(hwc_context_t *ctx, 140820242a75d65c410071434d639266311376a5b7f6Saurabh Shah hwc_display_contents_1_t* list) { 140920242a75d65c410071434d639266311376a5b7f6Saurabh Shah for(int index = 0; index < mCurrentFrame.layerCount; index++) { 1410c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah 1411f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mCurrentFrame.isFBComposed[index]) continue; 141220242a75d65c410071434d639266311376a5b7f6Saurabh Shah 1413c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[index]; 1414c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran private_handle_t *hnd = (private_handle_t *)layer->handle; 141515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ 1416404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R if(allocSplitVGPipesfor4k2k(ctx, index)){ 141715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna continue; 141815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 141915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 142015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 1421f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int mdpIndex = mCurrentFrame.layerToMDP[index]; 1422f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; 1423f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah info.pipeInfo = new MdpPipeInfoNonSplit; 1424327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah info.rot = NULL; 1425f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah MdpPipeInfoNonSplit& pipe_info = *(MdpPipeInfoNonSplit*)info.pipeInfo; 1426f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran ePipeType type = MDPCOMP_OV_ANY; 1427f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran 142820242a75d65c410071434d639266311376a5b7f6Saurabh Shah if(isYuvBuffer(hnd)) { 142920242a75d65c410071434d639266311376a5b7f6Saurabh Shah type = MDPCOMP_OV_VG; 1430319d01534158fe3edca7cf941a10b3423df0bd01Prabhanjan Kandula } else if(qdutils::MDPVersion::getInstance().is8x26() && 1431319d01534158fe3edca7cf941a10b3423df0bd01Prabhanjan Kandula (ctx->dpyAttr[HWC_DISPLAY_PRIMARY].xres > 1024)) { 1432319d01534158fe3edca7cf941a10b3423df0bd01Prabhanjan Kandula if(qhwc::needsScaling(layer)) 1433319d01534158fe3edca7cf941a10b3423df0bd01Prabhanjan Kandula type = MDPCOMP_OV_RGB; 143486c677669148a60b5d472fba407c2bfcdc0c05bePrabhanjan Kandula } else if(!qhwc::needsScaling(layer) 143511154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE 143611154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah && ctx->mMDP.version >= qdutils::MDSS_V5) { 1437f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran type = MDPCOMP_OV_DMA; 1438a85d9f9f2d5cd0555b409b1fc974a9ecec3fee56radhakrishna } else if(qhwc::needsScaling(layer) && 1439a85d9f9f2d5cd0555b409b1fc974a9ecec3fee56radhakrishna !(ctx->listStats[mDpy].yuvCount) && 1440a85d9f9f2d5cd0555b409b1fc974a9ecec3fee56radhakrishna ! qdutils::MDPVersion::getInstance().isRGBScalarSupported()){ 1441a85d9f9f2d5cd0555b409b1fc974a9ecec3fee56radhakrishna type = MDPCOMP_OV_VG; 1442f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran } 1443f8f3943c612a0e324b9fb01c858bf668d9e5b859Jeykumar Sankaran 14441a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah pipe_info.index = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); 1445c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran if(pipe_info.index == ovutils::OV_INVALID) { 144620242a75d65c410071434d639266311376a5b7f6Saurabh Shah ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d", 144720242a75d65c410071434d639266311376a5b7f6Saurabh Shah __FUNCTION__, (int) type); 1448c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return false; 1449c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 1450c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1451c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return true; 1452c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 1453c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 145415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishnaint MDPCompNonSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, 145515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna PipeLayerPair& PipeLayerPair) { 145615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpYUVPipeInfo& mdp_info = 145715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); 145815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); 145915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eIsFg isFg = IS_FG_OFF; 146015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; 146115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eDest lDest = mdp_info.lIndex; 146215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eDest rDest = mdp_info.rIndex; 146315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 146415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, 146515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna lDest, rDest, &PipeLayerPair.rot); 146615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna} 146715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 1468f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool MDPCompNonSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { 1469c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1470f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!isEnabled()) { 1471c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); 1472c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran return true; 147333650f2bc6096f20fb3974f5d1f98cb60ed6bdf4Naseer Ahmed } 147433650f2bc6096f20fb3974f5d1f98cb60ed6bdf4Naseer Ahmed 1475c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran if(!ctx || !list) { 1476c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran ALOGE("%s: invalid contxt or list",__FUNCTION__); 1477c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed return false; 1478c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1479c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1480ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { 1481ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); 1482ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula return true; 1483ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula } 1484ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula 1485e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan // Set the Handle timeout to true for MDP or MIXED composition. 1486e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) { 1487e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan sHandleTimeout = true; 1488e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan } 14890ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 1490c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran overlay::Overlay& ov = *ctx->mOverlay; 1491f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran LayerProp *layerProp = ctx->layerProp[mDpy]; 1492c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1493f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int numHwLayers = ctx->listStats[mDpy].numAppLayers; 1494f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) 1495c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran { 1496f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mCurrentFrame.isFBComposed[i]) continue; 1497f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1498c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran hwc_layer_1_t *layer = &list->hwLayers[i]; 1499327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 1500327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah if(!hnd) { 150108cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan if (!(layer->flags & HWC_COLOR_FILL)) { 150208cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan ALOGE("%s handle null", __FUNCTION__); 150308cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan return false; 150408cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan } 150508cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan // No PLAY for Color layer 150608cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan layerProp[i].mFlags &= ~HWC_MDPCOMP; 150708cbd816733f17c957411ae915f2543afea70b67Sushil Chauhan continue; 1508c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 15090ee9643396d2a257034a1c9b6d4eb6f6f7255e2dJeykumar Sankaran 1510f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int mdpIndex = mCurrentFrame.layerToMDP[i]; 1511f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 151215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) 151315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna { 151415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpYUVPipeInfo& pipe_info = 151515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; 151615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; 151715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexL = pipe_info.lIndex; 151815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexR = pipe_info.rIndex; 151915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int fd = hnd->fd; 15203d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu uint32_t offset = (uint32_t)hnd->offset; 152115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(rot) { 152215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna rot->queueBuffer(fd, offset); 152315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna fd = rot->getDstMemId(); 152415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna offset = rot->getDstOffset(); 152515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 152615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexL != ovutils::OV_INVALID) { 152715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destL = (ovutils::eDest)indexL; 152815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 152915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexL ); 153015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destL)) { 153115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for display:%d", 153215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__, mDpy); 153315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 153415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 153515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1536c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 153715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexR != ovutils::OV_INVALID) { 153815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destR = (ovutils::eDest)indexR; 153915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 154015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexR ); 154115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destR)) { 154215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for display:%d", 154315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__, mDpy); 154415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 154515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 154615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1547327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah } 154815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna else{ 154915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpPipeInfoNonSplit& pipe_info = 155015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(MdpPipeInfoNonSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; 155115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest dest = pipe_info.index; 155215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(dest == ovutils::OV_INVALID) { 155315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); 155415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 155515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1556c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 155715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { 155815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna continue; 155915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1560c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 156115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 156215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, 156315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hnd, dest ); 1564f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah 156515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int fd = hnd->fd; 15663d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu uint32_t offset = (uint32_t)hnd->offset; 1567327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 156815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; 156915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(rot) { 157015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(!rot->queueBuffer(fd, offset)) 157115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 157215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna fd = rot->getDstMemId(); 157315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna offset = rot->getDstOffset(); 157415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 157515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 157615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, dest)) { 157715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for display:%d ", 157815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__, mDpy); 157915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 158015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1581c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran } 1582c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1583c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran layerProp[i].mFlags &= ~HWC_MDPCOMP; 1584c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1585c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed return true; 1586c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 1587c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1588f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah//=============MDPCompSplit=================================================== 1589c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1590f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shahvoid MDPCompSplit::adjustForSourceSplit(hwc_context_t *ctx, 159115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hwc_display_contents_1_t* list){ 159215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //if 4kx2k yuv layer is totally present in either in left half 159315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //or right half then try splitting the yuv layer to avoid decimation 159415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int n4k2kYuvCount = ctx->listStats[mDpy].yuv4k2kCount; 159515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna const int lSplit = getLeftSplit(ctx, mDpy); 159615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna for(int index = 0; index < n4k2kYuvCount; index++){ 159715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int n4k2kYuvIndex = ctx->listStats[mDpy].yuv4k2kIndices[index]; 159815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hwc_layer_1_t* layer = &list->hwLayers[n4k2kYuvIndex]; 159915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hwc_rect_t dst = layer->displayFrame; 1600f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah if((dst.left > lSplit) || (dst.right < lSplit)) { 160115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna mCurrentFrame.mdpCount += 1; 160215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1603b64922f99edce921000e0aaf17bd3bcb686910d1Dileep Kumar Reddi if(mCurrentFrame.fbZ >= n4k2kYuvIndex){ 1604f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah mCurrentFrame.fbZ += 1; 1605f29205fd13a7d86767280bf1665149587faf86b2Saurabh Shah } 160615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 160715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna} 160815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 1609f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool MDPCompSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, 1610f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah MdpPipeInfoSplit& pipe_info, 16112e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah ePipeType type) { 16129640e380d8f815ef7ca71c1fdf23eb6f7b30db1eSaurabh Shah const int lSplit = getLeftSplit(ctx, mDpy); 1613f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1614f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran hwc_rect_t dst = layer->displayFrame; 16151a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah pipe_info.lIndex = ovutils::OV_INVALID; 16161a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah pipe_info.rIndex = ovutils::OV_INVALID; 16171a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah 16181a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah if (dst.left < lSplit) { 16191a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_LEFT); 1620f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(pipe_info.lIndex == ovutils::OV_INVALID) 1621f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 16221a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah } 16231a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah 16241a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah if(dst.right > lSplit) { 16251a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_RIGHT); 16261a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah if(pipe_info.rIndex == ovutils::OV_INVALID) 1627f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 1628f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran } 16291a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah 1630f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return true; 1631c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran} 1632c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1633f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool MDPCompSplit::allocLayerPipes(hwc_context_t *ctx, 163420242a75d65c410071434d639266311376a5b7f6Saurabh Shah hwc_display_contents_1_t* list) { 163520242a75d65c410071434d639266311376a5b7f6Saurabh Shah for(int index = 0 ; index < mCurrentFrame.layerCount; index++) { 163620242a75d65c410071434d639266311376a5b7f6Saurabh Shah 163720242a75d65c410071434d639266311376a5b7f6Saurabh Shah if(mCurrentFrame.isFBComposed[index]) continue; 1638c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 16395a107b4b7124301baf3b9e58089c7621fb9dfc95Jeykumar Sankaran hwc_layer_1_t* layer = &list->hwLayers[index]; 16405a107b4b7124301baf3b9e58089c7621fb9dfc95Jeykumar Sankaran private_handle_t *hnd = (private_handle_t *)layer->handle; 164115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hwc_rect_t dst = layer->displayFrame; 164215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna const int lSplit = getLeftSplit(ctx, mDpy); 164315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit){ 164415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if((dst.left > lSplit)||(dst.right < lSplit)){ 1645404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R if(allocSplitVGPipesfor4k2k(ctx, index)){ 164615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna continue; 164715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 164815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 164915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 16501bccd080a21bd76d606bef74b3ccac888f01f3d0Saurabh Shah int mdpIndex = mCurrentFrame.layerToMDP[index]; 16511bccd080a21bd76d606bef74b3ccac888f01f3d0Saurabh Shah PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; 1652f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah info.pipeInfo = new MdpPipeInfoSplit; 16533393d793e88663ee9147b04e11289020be3721c9Saurabh Shah info.rot = NULL; 1654f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah MdpPipeInfoSplit& pipe_info = *(MdpPipeInfoSplit*)info.pipeInfo; 1655c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran ePipeType type = MDPCOMP_OV_ANY; 1656c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 165720242a75d65c410071434d639266311376a5b7f6Saurabh Shah if(isYuvBuffer(hnd)) { 165820242a75d65c410071434d639266311376a5b7f6Saurabh Shah type = MDPCOMP_OV_VG; 165944625ff6484744d1307c0bb0d00e8c0ad90325ffSushil Chauhan } else if(!qhwc::needsScalingWithSplit(ctx, layer, mDpy) 166011154eed0599cd2e03bd0706341e14e05265b907Saurabh Shah && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE 166120242a75d65c410071434d639266311376a5b7f6Saurabh Shah && ctx->mMDP.version >= qdutils::MDSS_V5) { 1662c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran type = MDPCOMP_OV_DMA; 166320242a75d65c410071434d639266311376a5b7f6Saurabh Shah } 1664c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 1665c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { 166620242a75d65c410071434d639266311376a5b7f6Saurabh Shah ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d", 166720242a75d65c410071434d639266311376a5b7f6Saurabh Shah __FUNCTION__, (int) type); 166816791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed return false; 166916791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed } 1670c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1671c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed return true; 1672c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 16731a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah 167415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishnaint MDPCompSplit::configure4k2kYuv(hwc_context_t *ctx, hwc_layer_1_t *layer, 167515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna PipeLayerPair& PipeLayerPair) { 167615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna const int lSplit = getLeftSplit(ctx, mDpy); 167715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna hwc_rect_t dst = layer->displayFrame; 167815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if((dst.left > lSplit)||(dst.right < lSplit)){ 167915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpYUVPipeInfo& mdp_info = 168015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(static_cast<MdpYUVPipeInfo*>(PipeLayerPair.pipeInfo)); 168115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); 168215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eIsFg isFg = IS_FG_OFF; 168315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; 168415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eDest lDest = mdp_info.lIndex; 168515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna eDest rDest = mdp_info.rIndex; 168615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 168715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return configureSourceSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, 168815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna lDest, rDest, &PipeLayerPair.rot); 168915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 169015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna else{ 169115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return configure(ctx, layer, PipeLayerPair); 169215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 169315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna} 169415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 1695c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran/* 1696c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran * Configures pipe(s) for MDP composition 1697c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran */ 1698f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahint MDPCompSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, 16992e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah PipeLayerPair& PipeLayerPair) { 1700f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah MdpPipeInfoSplit& mdp_info = 1701f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); 1702327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); 1703327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eIsFg isFg = IS_FG_OFF; 1704327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; 1705327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eDest lDest = mdp_info.lIndex; 1706327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah eDest rDest = mdp_info.rIndex; 1707f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1708f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" 1709f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); 1710f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1711f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return configureSplit(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, 1712f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran rDest, &PipeLayerPair.rot); 1713c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 1714c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1715f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool MDPCompSplit::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { 1716c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1717f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(!isEnabled()) { 171816791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); 171916791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed return true; 1720c18b3a0ef41fe474fe37e2e1833ef1bb11c85b11Saurabh Shah } 1721c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1722c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed if(!ctx || !list) { 1723c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed ALOGE("%s: invalid contxt or list",__FUNCTION__); 172416791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed return false; 1725c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1726c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1727ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) { 1728ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__); 1729ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula return true; 1730ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula } 1731ac6a693721e84a8a8eebc50df0c1dcfce1e8e864Prabhanjan Kandula 1732e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan // Set the Handle timeout to true for MDP or MIXED composition. 1733e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount) { 1734e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan sHandleTimeout = true; 1735e7403150b1a7a50e5b2689dd40ae7825c4641fe2Ramkumar Radhakrishnan } 173616791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed 173716791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed overlay::Overlay& ov = *ctx->mOverlay; 1738f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran LayerProp *layerProp = ctx->layerProp[mDpy]; 1739c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1740f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int numHwLayers = ctx->listStats[mDpy].numAppLayers; 1741f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) 1742c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed { 1743f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran if(mCurrentFrame.isFBComposed[i]) continue; 1744f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 1745660267c43bb3370ab49f4e95562c027171d8fb83Naseer Ahmed hwc_layer_1_t *layer = &list->hwLayers[i]; 1746327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 1747327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah if(!hnd) { 1748327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah ALOGE("%s handle null", __FUNCTION__); 1749327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah return false; 1750327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah } 1751c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 175216791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { 1753c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed continue; 1754c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1755c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 1756f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int mdpIndex = mCurrentFrame.layerToMDP[i]; 1757f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 175815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(is4kx2kYuvBuffer(hnd) && sEnable4k2kYUVSplit) 175915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna { 176015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpYUVPipeInfo& pipe_info = 176115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(MdpYUVPipeInfo*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; 176215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; 176315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexL = pipe_info.lIndex; 176415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexR = pipe_info.rIndex; 176515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int fd = hnd->fd; 17663d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu uint32_t offset = (uint32_t)hnd->offset; 176715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(rot) { 176815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna rot->queueBuffer(fd, offset); 176915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna fd = rot->getDstMemId(); 177015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna offset = rot->getDstOffset(); 177115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 177215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexL != ovutils::OV_INVALID) { 177315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destL = (ovutils::eDest)indexL; 177415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 177515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexL ); 177615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destL)) { 177715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for display:%d", 177815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__, mDpy); 177915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 178015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 178115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 178215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna 178315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexR != ovutils::OV_INVALID) { 178415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destR = (ovutils::eDest)indexR; 178515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 178615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexR ); 178715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destR)) { 178815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for display:%d", 178915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__, mDpy); 179015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 179115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 179215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 179315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 179415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna else{ 179515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna MdpPipeInfoSplit& pipe_info = 179615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna *(MdpPipeInfoSplit*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; 179715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; 1798327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 179915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexL = pipe_info.lIndex; 180015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest indexR = pipe_info.rIndex; 1801f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran 180215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna int fd = hnd->fd; 18033d3705af561ebe7182b23fdc81e0b755d22b11ebPraveena Pachipulusu int offset = (uint32_t)hnd->offset; 1804327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 180515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(ctx->mAD->isModeOn()) { 180615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(ctx->mAD->draw(ctx, fd, offset)) { 1807404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R fd = ctx->mAD->getDstFd(); 1808404047f2c61687024048b04374ea736285ddded1Arun Kumar K.R offset = ctx->mAD->getDstOffset(); 180915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1810f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah } 1811f1c9077e23f3fd814c27445ad73f6967a1ce5d9eSaurabh Shah 181215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(rot) { 181315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna rot->queueBuffer(fd, offset); 181415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna fd = rot->getDstMemId(); 181515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna offset = rot->getDstOffset(); 181615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1817c8d563c4df56d25bf6ac6f38fb6703150458737aJeykumar Sankaran 181815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //************* play left mixer ********** 181915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexL != ovutils::OV_INVALID) { 182015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destL = (ovutils::eDest)indexL; 182115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 182215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexL ); 182315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destL)) { 182415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for left mixer", 182515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__); 182615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 182715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1828c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1829c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 183015c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna //************* play right mixer ********** 183115c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if(indexR != ovutils::OV_INVALID) { 183215c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ovutils::eDest destR = (ovutils::eDest)indexR; 183315c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ 183415c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna using pipe: %d", __FUNCTION__, layer, hnd, indexR ); 183515c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna if (!ov.queueBuffer(fd, offset, destR)) { 183615c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna ALOGE("%s: queueBuffer failed for right mixer", 183715c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna __FUNCTION__); 183815c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna return false; 183915c02b94dcc7d61d4af05ac32b3c4db3b3b8a1e6radhakrishna } 1840c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1841c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1842327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 184316791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed layerProp[i].mFlags &= ~HWC_MDPCOMP; 1844c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed } 1845327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah 184616791f95b2570b9d48fa360875676e9c8559c0a1Naseer Ahmed return true; 1847c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed} 18487dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 18497dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah//================MDPCompSrcSplit============================================== 18507dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shahbool MDPCompSrcSplit::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, 1851348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah MdpPipeInfoSplit& pipe_info, ePipeType type) { 18527dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 18537dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t dst = layer->displayFrame; 18547dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); 18557dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah pipe_info.lIndex = ovutils::OV_INVALID; 18567dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah pipe_info.rIndex = ovutils::OV_INVALID; 18577dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 18587dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //If 2 pipes are staged on a single stage of a mixer, then the left pipe 18597dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //should have a higher priority than the right one. Pipe priorities are 18607dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //starting with VG0, VG1 ... , RGB0 ..., DMA1 18617dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 18627dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //1 pipe by default for a layer 1863348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah pipe_info.lIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); 18647dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(pipe_info.lIndex == ovutils::OV_INVALID) { 18657dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(isYuvBuffer(hnd)) { 18667dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return false; 18677dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 18687dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah pipe_info.lIndex = getMdpPipe(ctx, MDPCOMP_OV_ANY, 18697dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah Overlay::MIXER_DEFAULT); 18707dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(pipe_info.lIndex == ovutils::OV_INVALID) { 18717dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return false; 18727dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 18737dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 18747dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 18757dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //If layer's crop width or dest width > 2048, use 2 pipes 18767dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if((dst.right - dst.left) > qdutils::MAX_DISPLAY_DIM or 18777dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah (crop.right - crop.left) > qdutils::MAX_DISPLAY_DIM) { 1878348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah pipe_info.rIndex = getMdpPipe(ctx, type, Overlay::MIXER_DEFAULT); 18797dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(pipe_info.rIndex == ovutils::OV_INVALID) { 1880348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah if(isYuvBuffer(hnd)) { 1881348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah return false; 1882348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah } 1883348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah pipe_info.rIndex = getMdpPipe(ctx, MDPCOMP_OV_ANY, 1884348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah Overlay::MIXER_DEFAULT); 1885348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah if(pipe_info.rIndex == ovutils::OV_INVALID) { 1886348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah return false; 1887348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah } 18887dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 18897dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 1890348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah // Return values 1891348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah // 1 Left pipe is higher priority, do nothing. 1892348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah // 0 Pipes of same priority. 1893348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah //-1 Right pipe is of higher priority, needs swap. 1894348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah if(ctx->mOverlay->comparePipePriority(pipe_info.lIndex, 1895348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah pipe_info.rIndex) == -1) { 1896348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah qhwc::swap(pipe_info.lIndex, pipe_info.rIndex); 18977dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 18987dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 1899348ca172f707a14925ba1652e9bcb3d4c2a695f4Saurabh Shah 19007dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return true; 19017dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah} 19027dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19037dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shahint MDPCompSrcSplit::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, 19047dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah PipeLayerPair& PipeLayerPair) { 19057dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 19067dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(!hnd) { 19077dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah ALOGE("%s: layer handle is NULL", __FUNCTION__); 19087dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return -1; 19097dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19107dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah MetaData_t *metadata = (MetaData_t *)hnd->base_metadata; 19117dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah MdpPipeInfoSplit& mdp_info = 19127dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah *(static_cast<MdpPipeInfoSplit*>(PipeLayerPair.pipeInfo)); 19137dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah Rotator **rot = &PipeLayerPair.rot; 19147dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah eZorder z = static_cast<eZorder>(mdp_info.zOrder); 19157dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah eIsFg isFg = IS_FG_OFF; 19167dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah eDest lDest = mdp_info.lIndex; 19177dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah eDest rDest = mdp_info.rIndex; 19187dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t crop = integerizeSourceCrop(layer->sourceCropf); 19197dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t dst = layer->displayFrame; 19207dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah int transform = layer->transform; 19217dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah eTransform orient = static_cast<eTransform>(transform); 19227dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah const int downscale = 0; 19237dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah int rotFlags = ROT_FLAGS_NONE; 19247dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah uint32_t format = ovutils::getMdpFormat(hnd->format, isTileRendered(hnd)); 19257dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah Whf whf(getWidth(hnd), getHeight(hnd), format, hnd->size); 19267dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19277dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" 19287dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah "dest_pipeR: %d",__FUNCTION__, layer, z, lDest, rDest); 19297dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19307dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah // Handle R/B swap 19317dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if (layer->flags & HWC_FORMAT_RB_SWAP) { 19327dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888) 19337dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888); 19347dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888) 19357dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888); 19367dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19377dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 1938e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; 1939e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah setMdpFlags(layer, mdpFlags, 0, transform); 19407dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19417dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(lDest != OV_INVALID && rDest != OV_INVALID) { 19427dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //Enable overfetch 1943e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah setMdpFlags(mdpFlags, OV_MDSS_MDP_DUAL_PIPE); 19447dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19457dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19467dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(isYuvBuffer(hnd) && (transform & HWC_TRANSFORM_ROT_90)) { 19477dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah (*rot) = ctx->mRotMgr->getNext(); 19487dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if((*rot) == NULL) return -1; 19495080cdee5662ba2eab9a058bda428217720dc694Saurabh Shah ctx->mLayerRotMap[mDpy]->add(layer, *rot); 19507dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //Configure rotator for pre-rotation 1951e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah if(configRotator(*rot, whf, crop, mdpFlags, orient, downscale) < 0) { 19527dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah ALOGE("%s: configRotator failed!", __FUNCTION__); 19537dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return -1; 19547dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19557dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah whf.format = (*rot)->getDstFormat(); 19567dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah updateSource(orient, whf, crop); 19577dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah rotFlags |= ROT_PREROTATED; 19587dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19597dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19607dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //If 2 pipes being used, divide layer into half, crop and dst 19617dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t cropL = crop; 19627dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t cropR = crop; 19637dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t dstL = dst; 19647dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t dstR = dst; 19657dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(lDest != OV_INVALID && rDest != OV_INVALID) { 19667dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropL.right = (crop.right + crop.left) / 2; 19677dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropR.left = cropL.right; 19687dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah sanitizeSourceCrop(cropL, cropR, hnd); 19697dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19707dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //Swap crops on H flip since 2 pipes are being used 19717dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if((orient & OVERLAY_TRANSFORM_FLIP_H) && (*rot) == NULL) { 19727dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah hwc_rect_t tmp = cropL; 19737dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropL = cropR; 19747dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropR = tmp; 19757dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19767dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19777dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah dstL.right = (dst.right + dst.left) / 2; 19787dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah dstR.left = dstL.right; 19797dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19807dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19817dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //For the mdp, since either we are pre-rotating or MDP does flips 19827dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah orient = OVERLAY_TRANSFORM_0; 19837dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah transform = 0; 19847dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19857dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //configure left pipe 19867dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(lDest != OV_INVALID) { 1987e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah PipeArgs pargL(mdpFlags, whf, z, isFg, 19887dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah static_cast<eRotFlags>(rotFlags), layer->planeAlpha, 19897dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah (ovutils::eBlending) getBlending(layer->blending)); 19907dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19917dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(configMdp(ctx->mOverlay, pargL, orient, 19927dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropL, dstL, metadata, lDest) < 0) { 19937dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah ALOGE("%s: commit failed for left mixer config", __FUNCTION__); 19947dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return -1; 19957dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19967dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 19977dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 19987dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah //configure right pipe 19997dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(rDest != OV_INVALID) { 2000e69d2f823985e2111ad652bf5a1a9c75ac34e5ceSaurabh Shah PipeArgs pargR(mdpFlags, whf, z, isFg, 20017dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah static_cast<eRotFlags>(rotFlags), 20027dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah layer->planeAlpha, 20037dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah (ovutils::eBlending) getBlending(layer->blending)); 20047dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah if(configMdp(ctx->mOverlay, pargR, orient, 20057dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah cropR, dstR, metadata, rDest) < 0) { 20067dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah ALOGE("%s: commit failed for right mixer config", __FUNCTION__); 20077dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return -1; 20087dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 20097dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah } 20107dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 20117dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah return 0; 20127dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah} 20137dc3e31e2a6de0ee146ad9146c12453ad5ce8fa7Saurabh Shah 2014c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed}; //namespace 2015c85d6b7428ded41c74a9455f580f3ee8b451bbdeNaseer Ahmed 2016