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