Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 3 | * Not a Contribution, Apache license notifications and license are retained |
| 4 | * for attribution purposes only. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #include "hwc_mdpcomp.h" |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 20 | #include <sys/ioctl.h> |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 21 | #include "external.h" |
Ramkumar Radhakrishnan | 47573e2 | 2012-11-07 11:36:41 -0800 | [diff] [blame] | 22 | #include "qdMetaData.h" |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 23 | #include "mdp_version.h" |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 24 | #include <overlayRotator.h> |
| 25 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 26 | using namespace overlay; |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 27 | using namespace qdutils; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 28 | using namespace overlay::utils; |
| 29 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 30 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 31 | namespace qhwc { |
| 32 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 33 | //==============MDPComp======================================================== |
| 34 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | IdleInvalidator *MDPComp::idleInvalidator = NULL; |
| 36 | bool MDPComp::sIdleFallBack = false; |
| 37 | bool MDPComp::sDebugLogs = false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 38 | bool MDPComp::sEnabled = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 39 | int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 40 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 41 | MDPComp* MDPComp::getObject(const int& width, int dpy) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 42 | if(width <= MAX_DISPLAY_DIM) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 43 | return new MDPCompLowRes(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 44 | } else { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 45 | return new MDPCompHighRes(dpy); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 46 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 47 | } |
| 48 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 49 | MDPComp::MDPComp(int dpy):mDpy(dpy){}; |
| 50 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 51 | void MDPComp::dump(android::String8& buf) |
| 52 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 53 | dumpsys_log(buf,"HWC Map for Dpy: %s \n", |
| 54 | mDpy ? "\"EXTERNAL\"" : "\"PRIMARY\""); |
| 55 | dumpsys_log(buf,"PREV_FRAME: layerCount:%2d mdpCount:%2d \ |
| 56 | cacheCount:%2d \n", mCachedFrame.layerCount, |
| 57 | mCachedFrame.mdpCount, mCachedFrame.cacheCount); |
| 58 | dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d \ |
| 59 | fbCount:%2d \n", mCurrentFrame.layerCount, |
| 60 | mCurrentFrame.mdpCount, mCurrentFrame.fbCount); |
| 61 | dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n", |
| 62 | (mCurrentFrame.needsRedraw? "YES" : "NO"), |
| 63 | mCurrentFrame.mdpCount, sMaxPipesPerMixer); |
| 64 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 65 | dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n"); |
| 66 | dumpsys_log(buf," --------------------------------------------- \n"); |
| 67 | for(int index = 0; index < mCurrentFrame.layerCount; index++ ) |
| 68 | dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n", |
| 69 | index, |
| 70 | (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"), |
| 71 | mCurrentFrame.layerToMDP[index], |
| 72 | (mCurrentFrame.isFBComposed[index] ? |
| 73 | (mCurrentFrame.needsRedraw ? "GLES" : "CACHE") : "MDP"), |
| 74 | (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ : |
| 75 | mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder)); |
| 76 | dumpsys_log(buf,"\n"); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | bool MDPComp::init(hwc_context_t *ctx) { |
| 80 | |
| 81 | if(!ctx) { |
| 82 | ALOGE("%s: Invalid hwc context!!",__FUNCTION__); |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | if(!setupBasePipe(ctx)) { |
| 87 | ALOGE("%s: Failed to setup primary base pipe", __FUNCTION__); |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | char property[PROPERTY_VALUE_MAX]; |
| 92 | |
| 93 | sEnabled = false; |
| 94 | if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) && |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 95 | (!strncmp(property, "1", PROPERTY_VALUE_MAX ) || |
| 96 | (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 97 | sEnabled = true; |
| 98 | } |
| 99 | |
| 100 | sDebugLogs = false; |
| 101 | if(property_get("debug.mdpcomp.logs", property, NULL) > 0) { |
| 102 | if(atoi(property) != 0) |
| 103 | sDebugLogs = true; |
| 104 | } |
| 105 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 106 | sMaxPipesPerMixer = MAX_PIPES_PER_MIXER; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 107 | if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) { |
| 108 | int val = atoi(property); |
| 109 | if(val >= 0) |
| 110 | sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 113 | unsigned long idle_timeout = DEFAULT_IDLE_TIME; |
| 114 | if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) { |
| 115 | if(atoi(property) != 0) |
| 116 | idle_timeout = atoi(property); |
| 117 | } |
| 118 | |
| 119 | //create Idle Invalidator |
| 120 | idleInvalidator = IdleInvalidator::getInstance(); |
| 121 | |
| 122 | if(idleInvalidator == NULL) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 123 | ALOGE("%s: failed to instantiate idleInvalidator object", __FUNCTION__); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 124 | } else { |
| 125 | idleInvalidator->init(timeout_handler, ctx, idle_timeout); |
| 126 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 127 | return true; |
| 128 | } |
| 129 | |
| 130 | void MDPComp::timeout_handler(void *udata) { |
| 131 | struct hwc_context_t* ctx = (struct hwc_context_t*)(udata); |
| 132 | |
| 133 | if(!ctx) { |
| 134 | ALOGE("%s: received empty data in timer callback", __FUNCTION__); |
| 135 | return; |
| 136 | } |
| 137 | |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 138 | if(!ctx->proc) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 139 | ALOGE("%s: HWC proc not registered", __FUNCTION__); |
| 140 | return; |
| 141 | } |
| 142 | sIdleFallBack = true; |
| 143 | /* Trigger SF to redraw the current frame */ |
Jesse Hall | 3be78d9 | 2012-08-21 15:12:23 -0700 | [diff] [blame] | 144 | ctx->proc->invalidate(ctx->proc); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 147 | void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 148 | hwc_display_contents_1_t* list) { |
| 149 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 150 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 151 | for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 152 | hwc_layer_1_t* layer = &(list->hwLayers[index]); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 153 | if(!mCurrentFrame.isFBComposed[index]) { |
| 154 | layerProp[index].mFlags |= HWC_MDPCOMP; |
| 155 | layer->compositionType = HWC_OVERLAY; |
| 156 | layer->hints |= HWC_HINT_CLEAR_FB; |
| 157 | mCachedFrame.hnd[index] = NULL; |
| 158 | } else { |
| 159 | if(!mCurrentFrame.needsRedraw) |
| 160 | layer->compositionType = HWC_OVERLAY; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 161 | } |
| 162 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 163 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 164 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 165 | /* |
| 166 | * Sets up BORDERFILL as default base pipe and detaches RGB0. |
| 167 | * Framebuffer is always updated using PLAY ioctl. |
| 168 | */ |
| 169 | bool MDPComp::setupBasePipe(hwc_context_t *ctx) { |
| 170 | const int dpy = HWC_DISPLAY_PRIMARY; |
| 171 | int fb_stride = ctx->dpyAttr[dpy].stride; |
| 172 | int fb_width = ctx->dpyAttr[dpy].xres; |
| 173 | int fb_height = ctx->dpyAttr[dpy].yres; |
| 174 | int fb_fd = ctx->dpyAttr[dpy].fd; |
| 175 | |
| 176 | mdp_overlay ovInfo; |
| 177 | msmfb_overlay_data ovData; |
| 178 | memset(&ovInfo, 0, sizeof(mdp_overlay)); |
| 179 | memset(&ovData, 0, sizeof(msmfb_overlay_data)); |
| 180 | |
| 181 | ovInfo.src.format = MDP_RGB_BORDERFILL; |
| 182 | ovInfo.src.width = fb_width; |
| 183 | ovInfo.src.height = fb_height; |
| 184 | ovInfo.src_rect.w = fb_width; |
| 185 | ovInfo.src_rect.h = fb_height; |
| 186 | ovInfo.dst_rect.w = fb_width; |
| 187 | ovInfo.dst_rect.h = fb_height; |
| 188 | ovInfo.id = MSMFB_NEW_REQUEST; |
| 189 | |
| 190 | if (ioctl(fb_fd, MSMFB_OVERLAY_SET, &ovInfo) < 0) { |
| 191 | ALOGE("Failed to call ioctl MSMFB_OVERLAY_SET err=%s", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 192 | strerror(errno)); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 193 | return false; |
| 194 | } |
| 195 | |
| 196 | ovData.id = ovInfo.id; |
| 197 | if (ioctl(fb_fd, MSMFB_OVERLAY_PLAY, &ovData) < 0) { |
| 198 | ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY err=%s", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 199 | strerror(errno)); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 200 | return false; |
| 201 | } |
| 202 | return true; |
| 203 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 204 | MDPComp::FrameInfo::FrameInfo() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 205 | reset(0); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 206 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 207 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 208 | void MDPComp::FrameInfo::reset(const int& numLayers) { |
| 209 | for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 210 | if(mdpToLayer[i].pipeInfo) { |
| 211 | delete mdpToLayer[i].pipeInfo; |
| 212 | mdpToLayer[i].pipeInfo = NULL; |
| 213 | //We dont own the rotator |
| 214 | mdpToLayer[i].rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 215 | } |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 216 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 217 | |
| 218 | memset(&mdpToLayer, 0, sizeof(mdpToLayer)); |
| 219 | memset(&layerToMDP, -1, sizeof(layerToMDP)); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 220 | memset(&isFBComposed, 1, sizeof(isFBComposed)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 221 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 222 | layerCount = numLayers; |
| 223 | fbCount = numLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 224 | mdpCount = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 225 | needsRedraw = false; |
| 226 | fbZ = 0; |
| 227 | } |
| 228 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 229 | void MDPComp::FrameInfo::map() { |
| 230 | // populate layer and MDP maps |
| 231 | int mdpIdx = 0; |
| 232 | for(int idx = 0; idx < layerCount; idx++) { |
| 233 | if(!isFBComposed[idx]) { |
| 234 | mdpToLayer[mdpIdx].listIndex = idx; |
| 235 | layerToMDP[idx] = mdpIdx++; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 240 | MDPComp::LayerCache::LayerCache() { |
| 241 | reset(); |
| 242 | } |
| 243 | |
| 244 | void MDPComp::LayerCache::reset() { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 245 | memset(&hnd, 0, sizeof(hnd)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 246 | mdpCount = 0; |
| 247 | cacheCount = 0; |
| 248 | layerCount = 0; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 249 | fbZ = -1; |
| 250 | } |
| 251 | |
| 252 | void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) { |
| 253 | const int numAppLayers = list->numHwLayers - 1; |
| 254 | for(int i = 0; i < numAppLayers; i++) { |
| 255 | hnd[i] = list->hwLayers[i].handle; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) { |
| 260 | mdpCount = curFrame.mdpCount; |
| 261 | cacheCount = curFrame.fbCount; |
| 262 | layerCount = curFrame.layerCount; |
| 263 | fbZ = curFrame.fbZ; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 264 | } |
| 265 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame^] | 266 | bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) { |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 267 | |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 268 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 269 | |
| 270 | if(!hnd) { |
| 271 | ALOGE("%s: layer handle is NULL", __FUNCTION__); |
| 272 | return false; |
| 273 | } |
| 274 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 275 | int hw_w = ctx->dpyAttr[mDpy].xres; |
| 276 | int hw_h = ctx->dpyAttr[mDpy].yres; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 277 | |
| 278 | hwc_rect_t sourceCrop = layer->sourceCrop; |
| 279 | hwc_rect_t displayFrame = layer->displayFrame; |
| 280 | |
| 281 | hwc_rect_t crop = sourceCrop; |
| 282 | int crop_w = crop.right - crop.left; |
| 283 | int crop_h = crop.bottom - crop.top; |
| 284 | |
| 285 | hwc_rect_t dst = displayFrame; |
| 286 | int dst_w = dst.right - dst.left; |
| 287 | int dst_h = dst.bottom - dst.top; |
| 288 | |
| 289 | if(dst.left < 0 || dst.top < 0 || dst.right > hw_w || dst.bottom > hw_h) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 290 | hwc_rect_t scissor = {0, 0, hw_w, hw_h }; |
| 291 | qhwc::calculate_crop_rects(crop, dst, scissor, layer->transform); |
| 292 | crop_w = crop.right - crop.left; |
| 293 | crop_h = crop.bottom - crop.top; |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 294 | } |
| 295 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 296 | /* Workaround for MDP HW limitation in DSI command mode panels where |
| 297 | * FPS will not go beyond 30 if buffers on RGB pipes are of width or height |
| 298 | * less than 5 pixels |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame^] | 299 | * There also is a HW limilation in MDP, minimum block size is 2x2 |
| 300 | * Fallback to GPU if height is less than 2. |
| 301 | */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 302 | if((crop_w < 5)||(crop_h < 5)) |
Jeykumar Sankaran | c18dbc2 | 2013-02-08 14:29:44 -0800 | [diff] [blame] | 303 | return false; |
| 304 | |
| 305 | return true; |
| 306 | } |
| 307 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 308 | ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 309 | overlay::Overlay& ov = *ctx->mOverlay; |
| 310 | ovutils::eDest mdp_pipe = ovutils::OV_INVALID; |
| 311 | |
| 312 | switch(type) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 313 | case MDPCOMP_OV_DMA: |
| 314 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy); |
| 315 | if(mdp_pipe != ovutils::OV_INVALID) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 316 | return mdp_pipe; |
| 317 | } |
| 318 | case MDPCOMP_OV_ANY: |
| 319 | case MDPCOMP_OV_RGB: |
| 320 | mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy); |
| 321 | if(mdp_pipe != ovutils::OV_INVALID) { |
| 322 | return mdp_pipe; |
| 323 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 324 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 325 | if(type == MDPCOMP_OV_RGB) { |
| 326 | //Requested only for RGB pipe |
| 327 | break; |
| 328 | } |
| 329 | case MDPCOMP_OV_VG: |
| 330 | return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy); |
| 331 | default: |
| 332 | ALOGE("%s: Invalid pipe type",__FUNCTION__); |
| 333 | return ovutils::OV_INVALID; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 334 | }; |
| 335 | return ovutils::OV_INVALID; |
| 336 | } |
| 337 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 338 | bool MDPComp::isFrameDoable(hwc_context_t *ctx) { |
| 339 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 340 | bool ret = true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 341 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 342 | if(!isEnabled()) { |
| 343 | ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 344 | ret = false; |
| 345 | } else if(ctx->mExtDispConfiguring) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 346 | ALOGD_IF( isDebug(),"%s: External Display connection is pending", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 347 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 348 | ret = false; |
| 349 | } else if(ctx->listStats[mDpy].needsAlphaScale |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 350 | && ctx->mMDP.version < qdutils::MDSS_V5) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 351 | ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 352 | ret = false; |
| 353 | } else if(ctx->isPaddingRound) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 354 | ctx->isPaddingRound = false; |
| 355 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 356 | ret = false; |
| 357 | } else if(sIdleFallBack) { |
| 358 | sIdleFallBack = false; |
| 359 | ALOGD_IF(isDebug(), "%s: idle fallback",__FUNCTION__); |
| 360 | ret = false; |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 363 | return ret; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 367 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 368 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 369 | hwc_display_contents_1_t* list){ |
| 370 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 371 | const int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 372 | |
| 373 | if(mDpy > HWC_DISPLAY_PRIMARY){ |
| 374 | ALOGD_IF(isDebug(), "%s: Cannot support External display(s)", |
| 375 | __FUNCTION__); |
| 376 | return false; |
| 377 | } |
| 378 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 379 | if(isSkipPresent(ctx, mDpy)) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 380 | ALOGD_IF(isDebug(),"%s: SKIP present: %d", |
| 381 | __FUNCTION__, |
| 382 | isSkipPresent(ctx, mDpy)); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 383 | return false; |
| 384 | } |
| 385 | |
| 386 | //MDP composition is not efficient if layer needs rotator. |
| 387 | for(int i = 0; i < numAppLayers; ++i) { |
| 388 | // As MDP h/w supports flip operation, use MDP comp only for |
| 389 | // 180 transforms. Fail for any transform involving 90 (90, 270). |
| 390 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 391 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 392 | |
| 393 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !isYuvBuffer(hnd)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 394 | ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__); |
| 395 | return false; |
| 396 | } |
| 397 | |
Sravan Kumar D.V.N | ad5d929 | 2013-04-24 14:23:04 +0530 | [diff] [blame^] | 398 | if(!isYuvBuffer(hnd) && !isValidDimension(ctx,layer)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 399 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width",__FUNCTION__); |
| 400 | return false; |
| 401 | } |
| 402 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 403 | |
| 404 | //If all above hard conditions are met we can do full or partial MDP comp. |
| 405 | bool ret = false; |
| 406 | if(fullMDPComp(ctx, list)) { |
| 407 | ret = true; |
| 408 | } else if (partialMDPComp(ctx, list)) { |
| 409 | ret = true; |
| 410 | } |
| 411 | return ret; |
| 412 | } |
| 413 | |
| 414 | bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 415 | //Setup mCurrentFrame |
| 416 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount; |
| 417 | mCurrentFrame.fbCount = 0; |
| 418 | mCurrentFrame.fbZ = -1; |
| 419 | memset(&mCurrentFrame.isFBComposed, 0, sizeof(mCurrentFrame.isFBComposed)); |
| 420 | |
| 421 | int mdpCount = mCurrentFrame.mdpCount; |
| 422 | if(mdpCount > sMaxPipesPerMixer) { |
| 423 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 424 | return false; |
| 425 | } |
| 426 | |
| 427 | int numPipesNeeded = pipesNeeded(ctx, list); |
| 428 | int availPipes = getAvailablePipes(ctx); |
| 429 | |
| 430 | if(numPipesNeeded > availPipes) { |
| 431 | ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d", |
| 432 | __FUNCTION__, numPipesNeeded, availPipes); |
| 433 | return false; |
| 434 | } |
| 435 | |
| 436 | return true; |
| 437 | } |
| 438 | |
| 439 | bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) |
| 440 | { |
| 441 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 442 | //Setup mCurrentFrame |
| 443 | mCurrentFrame.reset(numAppLayers); |
| 444 | updateLayerCache(ctx, list); |
| 445 | updateYUV(ctx, list); |
| 446 | batchLayers(); //sets up fbZ also |
| 447 | |
| 448 | int mdpCount = mCurrentFrame.mdpCount; |
| 449 | if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used |
| 450 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 451 | return false; |
| 452 | } |
| 453 | |
| 454 | int numPipesNeeded = pipesNeeded(ctx, list); |
| 455 | int availPipes = getAvailablePipes(ctx); |
| 456 | |
| 457 | if(numPipesNeeded > availPipes) { |
| 458 | ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d", |
| 459 | __FUNCTION__, numPipesNeeded, availPipes); |
| 460 | return false; |
| 461 | } |
| 462 | |
| 463 | return true; |
| 464 | } |
| 465 | |
| 466 | bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx, |
| 467 | hwc_display_contents_1_t* list){ |
| 468 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 469 | mCurrentFrame.reset(numAppLayers); |
| 470 | updateYUV(ctx, list); |
| 471 | int mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount; |
| 472 | int fbNeeded = int(mCurrentFrame.fbCount != 0); |
| 473 | |
| 474 | if(!isYuvPresent(ctx, mDpy)) { |
| 475 | return false; |
| 476 | } |
| 477 | |
| 478 | if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { |
| 479 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 480 | return false; |
| 481 | } |
| 482 | |
| 483 | int numPipesNeeded = pipesNeeded(ctx, list); |
| 484 | int availPipes = getAvailablePipes(ctx); |
| 485 | if(numPipesNeeded > availPipes) { |
| 486 | ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d", |
| 487 | __FUNCTION__, numPipesNeeded, availPipes); |
| 488 | return false; |
| 489 | } |
| 490 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 491 | return true; |
| 492 | } |
| 493 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 494 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 495 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 496 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 497 | if(isSkipLayer(layer)) { |
| 498 | ALOGE("%s: Unable to bypass skipped YUV", __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 499 | return false; |
| 500 | } |
| 501 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 502 | if(isSecuring(ctx, layer)) { |
| 503 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 504 | return false; |
| 505 | } |
| 506 | |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 507 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 508 | const uint32_t downscale = |
| 509 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 510 | hwc_rect_t crop = layer->sourceCrop; |
| 511 | hwc_rect_t dst = layer->displayFrame; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 512 | int cWidth = crop.right - crop.left; |
| 513 | int cHeight = crop.bottom - crop.top; |
| 514 | int dWidth = dst.right - dst.left; |
| 515 | int dHeight = dst.bottom - dst.top; |
| 516 | |
Amara Venkata Mastan Manoj Kumar | 6fa8672 | 2013-04-12 17:11:14 -0700 | [diff] [blame] | 517 | if(layer->transform & HAL_TRANSFORM_ROT_90) { |
| 518 | swap(cWidth, cHeight); |
| 519 | } |
| 520 | |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 521 | if(cWidth > MAX_DISPLAY_DIM || (cWidth/dWidth) > downscale || |
| 522 | (cHeight/dHeight) > downscale) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 523 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 524 | } |
| 525 | return true; |
| 526 | } |
| 527 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 528 | void MDPComp::batchLayers() { |
| 529 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 530 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 531 | * But cached ones can be marked for MDP*/ |
| 532 | |
| 533 | int maxBatchStart = -1; |
| 534 | int maxBatchCount = 0; |
| 535 | |
| 536 | /* All or Nothing is cached. No batching needed */ |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 537 | if(!mCurrentFrame.fbCount) { |
| 538 | mCurrentFrame.fbZ = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 539 | return; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 540 | } |
| 541 | if(!mCurrentFrame.mdpCount) { |
| 542 | mCurrentFrame.fbZ = 0; |
| 543 | return; |
| 544 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 545 | |
| 546 | /* Search for max number of contiguous (cached) layers */ |
| 547 | int i = 0; |
| 548 | while (i < mCurrentFrame.layerCount) { |
| 549 | int count = 0; |
| 550 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 551 | count++; i++; |
| 552 | } |
| 553 | if(count > maxBatchCount) { |
| 554 | maxBatchCount = count; |
| 555 | maxBatchStart = i - count; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 556 | mCurrentFrame.fbZ = maxBatchStart; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 557 | } |
| 558 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 559 | } |
| 560 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 561 | /* reset rest of the layers for MDP comp */ |
| 562 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 563 | if(i != maxBatchStart){ |
| 564 | mCurrentFrame.isFBComposed[i] = false; |
| 565 | } else { |
| 566 | i += maxBatchCount; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | mCurrentFrame.fbCount = maxBatchCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 571 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 572 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 573 | |
| 574 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 575 | mCurrentFrame.fbCount); |
| 576 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 577 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 578 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 579 | hwc_display_contents_1_t* list) { |
| 580 | |
| 581 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 582 | int numCacheableLayers = 0; |
| 583 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 584 | for(int i = 0; i < numAppLayers; i++) { |
| 585 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 586 | numCacheableLayers++; |
| 587 | mCurrentFrame.isFBComposed[i] = true; |
| 588 | } else { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 589 | mCurrentFrame.isFBComposed[i] = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 590 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 591 | } |
| 592 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 593 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 594 | mCurrentFrame.fbCount = numCacheableLayers; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 595 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 596 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 597 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 598 | } |
| 599 | |
| 600 | int MDPComp::getAvailablePipes(hwc_context_t* ctx) { |
| 601 | int numDMAPipes = qdutils::MDPVersion::getInstance().getDMAPipes(); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 602 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 603 | |
| 604 | int numAvailable = ov.availablePipes(mDpy); |
| 605 | |
| 606 | //Reserve DMA for rotator |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 607 | if(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 608 | numAvailable -= numDMAPipes; |
| 609 | |
| 610 | //Reserve pipe(s)for FB |
| 611 | if(mCurrentFrame.fbCount) |
| 612 | numAvailable -= pipesForFB(); |
| 613 | |
| 614 | return numAvailable; |
| 615 | } |
| 616 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 617 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 618 | |
| 619 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
| 620 | for(int index = 0;index < nYuvCount; index++){ |
| 621 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 622 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 623 | |
| 624 | if(!isYUVDoable(ctx, layer)) { |
| 625 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 626 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 627 | mCurrentFrame.fbCount++; |
| 628 | } |
| 629 | } else { |
| 630 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 631 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 632 | mCurrentFrame.fbCount--; |
| 633 | } |
| 634 | } |
| 635 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 636 | |
| 637 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 638 | mCurrentFrame.fbCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 639 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 640 | mCurrentFrame.fbCount); |
| 641 | } |
| 642 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 643 | bool MDPComp::programMDP(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 644 | if(!allocLayerPipes(ctx, list)) { |
| 645 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 646 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 647 | } |
| 648 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 649 | bool fbBatch = false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 650 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 651 | index++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 652 | if(!mCurrentFrame.isFBComposed[index]) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 653 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 654 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 655 | |
| 656 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 657 | cur_pipe->zOrder = mdpNextZOrder++; |
| 658 | |
| 659 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 660 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 661 | layer %d",__FUNCTION__, index); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 662 | return false; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 663 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 664 | } else if(fbBatch == false) { |
| 665 | mdpNextZOrder++; |
| 666 | fbBatch = true; |
| 667 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 668 | } |
| 669 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 670 | return true; |
| 671 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 672 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 673 | bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 674 | if(!allocLayerPipes(ctx, list)) { |
| 675 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 676 | return false; |
| 677 | } |
| 678 | //If we are in this block, it means we have yuv + rgb layers both |
| 679 | int mdpIdx = 0; |
| 680 | for (int index = 0; index < mCurrentFrame.layerCount; index++) { |
| 681 | if(!mCurrentFrame.isFBComposed[index]) { |
| 682 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 683 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 684 | MdpPipeInfo* cur_pipe = |
| 685 | mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 686 | cur_pipe->zOrder = mdpIdx++; |
| 687 | |
| 688 | if(configure(ctx, layer, |
| 689 | mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 690 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 691 | layer %d",__FUNCTION__, index); |
| 692 | return false; |
| 693 | } |
| 694 | } |
| 695 | } |
| 696 | return true; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | int MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 700 | |
| 701 | //reset old data |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 702 | const int numLayers = ctx->listStats[mDpy].numAppLayers; |
| 703 | mCurrentFrame.reset(numLayers); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 704 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 705 | //Hard conditions, if not met, cannot do MDP comp |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 706 | if(!isFrameDoable(ctx)) { |
| 707 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 708 | __FUNCTION__); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 709 | mCurrentFrame.reset(numLayers); |
| 710 | mCachedFrame.cacheAll(list); |
| 711 | mCachedFrame.updateCounts(mCurrentFrame); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 712 | return 0; |
| 713 | } |
| 714 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 715 | //Check whether layers marked for MDP Composition is actually doable. |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 716 | if(isFullFrameDoable(ctx, list)){ |
| 717 | if(mCurrentFrame.mdpCount) { |
| 718 | mCurrentFrame.map(); |
| 719 | //Acquire and Program MDP pipes |
| 720 | if(!programMDP(ctx, list)) { |
| 721 | mCurrentFrame.reset(numLayers); |
| 722 | mCachedFrame.cacheAll(list); |
| 723 | } |
| 724 | } |
| 725 | } else if(isOnlyVideoDoable(ctx, list)) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 726 | //All layers marked for MDP comp cannot be bypassed. |
| 727 | //Try to compose atleast YUV layers through MDP comp and let |
| 728 | //all the RGB layers compose in FB |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 729 | //Destination over |
| 730 | mCurrentFrame.fbZ = -1; |
| 731 | if(mCurrentFrame.fbCount) |
| 732 | mCurrentFrame.fbZ = ctx->listStats[mDpy].yuvCount; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 733 | |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 734 | mCurrentFrame.map(); |
| 735 | if(!programYUV(ctx, list)) { |
| 736 | mCurrentFrame.reset(numLayers); |
| 737 | mCachedFrame.cacheAll(list); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 738 | } |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 739 | } else { |
| 740 | mCurrentFrame.reset(numLayers); |
| 741 | mCachedFrame.cacheAll(list); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 742 | } |
| 743 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 744 | /* Any change in composition types needs an FB refresh*/ |
| 745 | if(mCurrentFrame.fbCount && |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 746 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 747 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 748 | (mCurrentFrame.fbZ != mCachedFrame.fbZ) || |
| 749 | (!mCurrentFrame.mdpCount) || |
| 750 | (list->flags & HWC_GEOMETRY_CHANGED) || |
| 751 | isSkipPresent(ctx, mDpy) || |
| 752 | (mDpy > HWC_DISPLAY_PRIMARY))) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 753 | mCurrentFrame.needsRedraw = true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 754 | } |
| 755 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 756 | //UpdateLayerFlags |
| 757 | setMDPCompLayerFlags(ctx, list); |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 758 | mCachedFrame.updateCounts(mCurrentFrame); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 759 | |
| 760 | if(isDebug()) { |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 761 | ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED)); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 762 | android::String8 sDump(""); |
| 763 | dump(sDump); |
| 764 | ALOGE("%s",sDump.string()); |
| 765 | } |
| 766 | |
| 767 | return mCurrentFrame.fbZ; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 768 | } |
| 769 | |
| 770 | //=============MDPCompLowRes=================================================== |
| 771 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 772 | /* |
| 773 | * Configures pipe(s) for MDP composition |
| 774 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 775 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 776 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 777 | MdpPipeInfoLowRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 778 | *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 779 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 780 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 781 | eIsFg isFg = IS_FG_OFF; |
| 782 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 783 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 784 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 785 | __FUNCTION__, layer, zOrder, dest); |
| 786 | |
| 787 | return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
| 788 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 789 | } |
| 790 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 791 | int MDPCompLowRes::pipesNeeded(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 792 | hwc_display_contents_1_t* list) { |
| 793 | return mCurrentFrame.mdpCount; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 796 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 797 | hwc_display_contents_1_t* list) { |
| 798 | if(isYuvPresent(ctx, mDpy)) { |
| 799 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 800 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 801 | for(int index = 0; index < nYuvCount ; index ++) { |
| 802 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 803 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 804 | if(mCurrentFrame.isFBComposed[nYuvIndex]) |
| 805 | continue; |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 806 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 807 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 808 | |
| 809 | int mdpIndex = mCurrentFrame.layerToMDP[nYuvIndex]; |
| 810 | |
| 811 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 812 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 813 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 814 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 815 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 816 | pipe_info.index = getMdpPipe(ctx, MDPCOMP_OV_VG); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 817 | if(pipe_info.index == ovutils::OV_INVALID) { |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 818 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for Videos", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 819 | __FUNCTION__); |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 820 | return false; |
| 821 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 822 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 823 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 824 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 825 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++ ) { |
| 826 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 827 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 828 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 829 | |
| 830 | if(isYuvBuffer(hnd)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 831 | continue; |
| 832 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 833 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 834 | |
| 835 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 836 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 837 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 838 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
| 839 | |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 840 | ePipeType type = MDPCOMP_OV_ANY; |
| 841 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 842 | if(!qhwc::needsScaling(layer) |
| 843 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 844 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 845 | type = MDPCOMP_OV_DMA; |
| 846 | } |
| 847 | |
| 848 | pipe_info.index = getMdpPipe(ctx, type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 849 | if(pipe_info.index == ovutils::OV_INVALID) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 850 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 851 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 854 | return true; |
| 855 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 856 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 857 | bool MDPCompLowRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 858 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 859 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 860 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 861 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 862 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 863 | |
| 864 | if(!ctx || !list) { |
| 865 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 866 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 869 | /* reset Invalidator */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 870 | if(idleInvalidator && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 871 | idleInvalidator->markForSleep(); |
| 872 | |
| 873 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 874 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 875 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 876 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 877 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 878 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 879 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 880 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 881 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 882 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 883 | if(!hnd) { |
| 884 | ALOGE("%s handle null", __FUNCTION__); |
| 885 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 886 | } |
| 887 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 888 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 889 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 890 | MdpPipeInfoLowRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 891 | *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 892 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 893 | if(dest == ovutils::OV_INVALID) { |
| 894 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 895 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 896 | } |
| 897 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 898 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 899 | continue; |
| 900 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 901 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 902 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 903 | using pipe: %d", __FUNCTION__, layer, |
| 904 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 905 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 906 | int fd = hnd->fd; |
| 907 | uint32_t offset = hnd->offset; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 908 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 909 | if(rot) { |
| 910 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 911 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 912 | fd = rot->getDstMemId(); |
| 913 | offset = rot->getDstOffset(); |
| 914 | } |
| 915 | |
| 916 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 917 | ALOGE("%s: queueBuffer failed for external", __FUNCTION__); |
| 918 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 919 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 920 | |
| 921 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 922 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 923 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 924 | } |
| 925 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 926 | //=============MDPCompHighRes=================================================== |
| 927 | |
| 928 | int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 929 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 930 | int pipesNeeded = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 931 | int hw_w = ctx->dpyAttr[mDpy].xres; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 932 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 933 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 934 | if(!mCurrentFrame.isFBComposed[i]) { |
| 935 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 936 | hwc_rect_t dst = layer->displayFrame; |
| 937 | if(dst.left > hw_w/2) { |
| 938 | pipesNeeded++; |
| 939 | } else if(dst.right <= hw_w/2) { |
| 940 | pipesNeeded++; |
| 941 | } else { |
| 942 | pipesNeeded += 2; |
| 943 | } |
| 944 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 945 | } |
| 946 | return pipesNeeded; |
| 947 | } |
| 948 | |
| 949 | bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 950 | MdpPipeInfoHighRes& pipe_info, |
| 951 | ePipeType type) { |
| 952 | int hw_w = ctx->dpyAttr[mDpy].xres; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 953 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 954 | hwc_rect_t dst = layer->displayFrame; |
| 955 | if(dst.left > hw_w/2) { |
| 956 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 957 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 958 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
| 959 | return false; |
| 960 | } else if (dst.right <= hw_w/2) { |
| 961 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 962 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 963 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 964 | return false; |
| 965 | } else { |
| 966 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 967 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 968 | if(pipe_info.rIndex == ovutils::OV_INVALID || |
| 969 | pipe_info.lIndex == ovutils::OV_INVALID) |
| 970 | return false; |
| 971 | } |
| 972 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 976 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 977 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 978 | int layer_count = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 979 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 980 | if(isYuvPresent(ctx, mDpy)) { |
| 981 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 982 | |
| 983 | for(int index = 0; index < nYuvCount; index ++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 984 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 985 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 986 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[nYuvIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 987 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 988 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 989 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 990 | if(!acquireMDPPipes(ctx, layer, pipe_info,MDPCOMP_OV_VG)) { |
| 991 | ALOGD_IF(isDebug(),"%s: Unable to get pipe for videos", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 992 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 993 | //TODO: windback pipebook data on fail |
| 994 | return false; |
| 995 | } |
| 996 | pipe_info.zOrder = nYuvIndex; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | for(int index = 0 ; index < layer_count ; index++ ) { |
| 1001 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 1002 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1003 | |
| 1004 | if(isYuvBuffer(hnd)) |
| 1005 | continue; |
| 1006 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1007 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[index]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1008 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 1009 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1010 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 1011 | |
| 1012 | ePipeType type = MDPCOMP_OV_ANY; |
| 1013 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 1014 | if(!qhwc::needsScaling(layer) |
| 1015 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 1016 | && ctx->mMDP.version >= qdutils::MDSS_V5) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1017 | type = MDPCOMP_OV_DMA; |
| 1018 | |
| 1019 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
| 1020 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 1021 | //TODO: windback pipebook data on fail |
| 1022 | return false; |
| 1023 | } |
| 1024 | pipe_info.zOrder = index; |
| 1025 | } |
| 1026 | return true; |
| 1027 | } |
| 1028 | /* |
| 1029 | * Configures pipe(s) for MDP composition |
| 1030 | */ |
| 1031 | int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1032 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1033 | MdpPipeInfoHighRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1034 | *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1035 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 1036 | eIsFg isFg = IS_FG_OFF; |
| 1037 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 1038 | eDest lDest = mdp_info.lIndex; |
| 1039 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1040 | |
| 1041 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 1042 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 1043 | |
| 1044 | return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
| 1045 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 1049 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1050 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1051 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 1052 | return true; |
| 1053 | } |
| 1054 | |
| 1055 | if(!ctx || !list) { |
| 1056 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1057 | return false; |
| 1058 | } |
| 1059 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1060 | /* reset Invalidator */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1061 | if(idleInvalidator && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1062 | idleInvalidator->markForSleep(); |
| 1063 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 1064 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1065 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1066 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1067 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 1068 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1069 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1070 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 1071 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1072 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1073 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 1074 | if(!hnd) { |
| 1075 | ALOGE("%s handle null", __FUNCTION__); |
| 1076 | return false; |
| 1077 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1078 | |
| 1079 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 1080 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1081 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1082 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1083 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 1084 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1085 | MdpPipeInfoHighRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1086 | *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 1087 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1088 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1089 | ovutils::eDest indexL = pipe_info.lIndex; |
| 1090 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1091 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1092 | int fd = hnd->fd; |
| 1093 | int offset = hnd->offset; |
| 1094 | |
| 1095 | if(rot) { |
| 1096 | rot->queueBuffer(fd, offset); |
| 1097 | fd = rot->getDstMemId(); |
| 1098 | offset = rot->getDstOffset(); |
| 1099 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1100 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1101 | //************* play left mixer ********** |
| 1102 | if(indexL != ovutils::OV_INVALID) { |
| 1103 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1104 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1105 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1106 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 1107 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 1108 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | //************* play right mixer ********** |
| 1113 | if(indexR != ovutils::OV_INVALID) { |
| 1114 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1115 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1116 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1117 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1118 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1119 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1120 | } |
| 1121 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1122 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1123 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1124 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1125 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1126 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1127 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1128 | }; //namespace |
| 1129 | |