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