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 | |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 336 | if(ctx->isPaddingRound) { |
| 337 | ctx->isPaddingRound = false; |
| 338 | ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__); |
| 339 | return false; |
| 340 | } |
| 341 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 342 | return true; |
| 343 | } |
| 344 | |
| 345 | /* Checks for conditions where all the layers marked for MDP comp cannot be |
| 346 | * bypassed. On such conditions we try to bypass atleast YUV layers */ |
| 347 | bool MDPComp::isFullFrameDoable(hwc_context_t *ctx, |
| 348 | hwc_display_contents_1_t* list){ |
| 349 | |
| 350 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 351 | int mdpCount = mCurrentFrame.layerCount - mCurrentFrame.fbCount; |
| 352 | int fbNeeded = int(mCurrentFrame.fbCount != 0); |
| 353 | |
| 354 | if(mDpy > HWC_DISPLAY_PRIMARY){ |
| 355 | ALOGD_IF(isDebug(), "%s: Cannot support External display(s)", |
| 356 | __FUNCTION__); |
| 357 | return false; |
| 358 | } |
| 359 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 360 | if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 361 | ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__); |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | if(pipesNeeded(ctx, list) > getAvailablePipes(ctx)) { |
| 366 | ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes",__FUNCTION__); |
| 367 | return false; |
| 368 | } |
| 369 | |
| 370 | if(isSkipPresent(ctx, mDpy)) { |
| 371 | ALOGD_IF(isDebug(), "%s: Skip layers present",__FUNCTION__); |
| 372 | return false; |
| 373 | } |
| 374 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 375 | //FB composition on idle timeout |
| 376 | if(sIdleFallBack) { |
| 377 | sIdleFallBack = false; |
| 378 | ALOGD_IF(isDebug(), "%s: idle fallback",__FUNCTION__); |
| 379 | return false; |
| 380 | } |
| 381 | |
| 382 | //MDP composition is not efficient if layer needs rotator. |
| 383 | for(int i = 0; i < numAppLayers; ++i) { |
| 384 | // As MDP h/w supports flip operation, use MDP comp only for |
| 385 | // 180 transforms. Fail for any transform involving 90 (90, 270). |
| 386 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 387 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 388 | |
| 389 | if(layer->transform & HWC_TRANSFORM_ROT_90 && !isYuvBuffer(hnd)) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 390 | ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__); |
| 391 | return false; |
| 392 | } |
| 393 | |
| 394 | if(!isYuvBuffer(hnd) && !isWidthValid(ctx,layer)) { |
| 395 | ALOGD_IF(isDebug(), "%s: Buffer is of invalid width",__FUNCTION__); |
| 396 | return false; |
| 397 | } |
| 398 | } |
| 399 | return true; |
| 400 | } |
| 401 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 402 | /* Checks for conditions where YUV layers cannot be bypassed */ |
| 403 | bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 404 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 405 | if(isSkipLayer(layer)) { |
| 406 | ALOGE("%s: Unable to bypass skipped YUV", __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 407 | return false; |
| 408 | } |
| 409 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 410 | if(isSecuring(ctx, layer)) { |
| 411 | ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__); |
| 412 | return false; |
| 413 | } |
| 414 | |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 415 | if(!qdutils::MDPVersion::getInstance().supportsDecimation()) { |
| 416 | const uint32_t downscale = |
| 417 | qdutils::MDPVersion::getInstance().getMaxMDPDownscale(); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 418 | hwc_rect_t crop = layer->sourceCrop; |
| 419 | hwc_rect_t dst = layer->displayFrame; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 420 | int cWidth = crop.right - crop.left; |
| 421 | int cHeight = crop.bottom - crop.top; |
| 422 | int dWidth = dst.right - dst.left; |
| 423 | int dHeight = dst.bottom - dst.top; |
| 424 | |
Amara Venkata Mastan Manoj Kumar | 6fa8672 | 2013-04-12 17:11:14 -0700 | [diff] [blame] | 425 | if(layer->transform & HAL_TRANSFORM_ROT_90) { |
| 426 | swap(cWidth, cHeight); |
| 427 | } |
| 428 | |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 429 | if(cWidth > MAX_DISPLAY_DIM || (cWidth/dWidth) > downscale || |
| 430 | (cHeight/dHeight) > downscale) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 431 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 432 | } |
| 433 | return true; |
| 434 | } |
| 435 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 436 | void MDPComp::batchLayers() { |
| 437 | /* Idea is to keep as many contiguous non-updating(cached) layers in FB and |
| 438 | * send rest of them through MDP. NEVER mark an updating layer for caching. |
| 439 | * But cached ones can be marked for MDP*/ |
| 440 | |
| 441 | int maxBatchStart = -1; |
| 442 | int maxBatchCount = 0; |
| 443 | |
| 444 | /* All or Nothing is cached. No batching needed */ |
| 445 | if(!mCurrentFrame.fbCount || |
| 446 | (mCurrentFrame.fbCount == mCurrentFrame.layerCount)) |
| 447 | return; |
| 448 | |
| 449 | /* Search for max number of contiguous (cached) layers */ |
| 450 | int i = 0; |
| 451 | while (i < mCurrentFrame.layerCount) { |
| 452 | int count = 0; |
| 453 | while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) { |
| 454 | count++; i++; |
| 455 | } |
| 456 | if(count > maxBatchCount) { |
| 457 | maxBatchCount = count; |
| 458 | maxBatchStart = i - count; |
| 459 | } |
| 460 | if(i < mCurrentFrame.layerCount) i++; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 461 | } |
| 462 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 463 | /* reset rest of the layers for MDP comp */ |
| 464 | for(int i = 0; i < mCurrentFrame.layerCount; i++) { |
| 465 | if(i != maxBatchStart){ |
| 466 | mCurrentFrame.isFBComposed[i] = false; |
| 467 | } else { |
| 468 | i += maxBatchCount; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | mCurrentFrame.fbCount = maxBatchCount; |
| 473 | |
| 474 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 475 | mCurrentFrame.fbCount); |
| 476 | } |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 477 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 478 | void MDPComp::updateLayerCache(hwc_context_t* ctx, |
| 479 | hwc_display_contents_1_t* list) { |
| 480 | |
| 481 | int numAppLayers = ctx->listStats[mDpy].numAppLayers; |
| 482 | int numCacheableLayers = 0; |
| 483 | |
| 484 | if((list->flags & HWC_GEOMETRY_CHANGED) || (isSkipPresent(ctx, mDpy))) { |
| 485 | ALOGD_IF(isDebug(),"%s: No Caching: \ |
| 486 | GEOMETRY change: %d SKIP present: %d", __FUNCTION__, |
| 487 | (list->flags & HWC_GEOMETRY_CHANGED),isSkipPresent(ctx, mDpy)); |
| 488 | mCachedFrame.reset(); |
| 489 | return; |
| 490 | } |
| 491 | |
| 492 | for(int i = 0; i < numAppLayers; i++) { |
| 493 | if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) { |
| 494 | numCacheableLayers++; |
| 495 | mCurrentFrame.isFBComposed[i] = true; |
| 496 | } else { |
| 497 | mCachedFrame.hnd[i] = list->hwLayers[i].handle; |
| 498 | } |
| 499 | } |
| 500 | mCurrentFrame.fbCount = numCacheableLayers; |
| 501 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers); |
| 502 | } |
| 503 | |
| 504 | int MDPComp::getAvailablePipes(hwc_context_t* ctx) { |
| 505 | int numDMAPipes = qdutils::MDPVersion::getInstance().getDMAPipes(); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 506 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 507 | |
| 508 | int numAvailable = ov.availablePipes(mDpy); |
| 509 | |
| 510 | //Reserve DMA for rotator |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 511 | if(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE) |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 512 | numAvailable -= numDMAPipes; |
| 513 | |
| 514 | //Reserve pipe(s)for FB |
| 515 | if(mCurrentFrame.fbCount) |
| 516 | numAvailable -= pipesForFB(); |
| 517 | |
| 518 | return numAvailable; |
| 519 | } |
| 520 | |
| 521 | void MDPComp::resetFrameForFB(hwc_context_t* ctx, |
| 522 | hwc_display_contents_1_t* list) { |
| 523 | mCurrentFrame.fbCount = mCurrentFrame.layerCount; |
| 524 | memset(&mCurrentFrame.isFBComposed, 1, |
| 525 | sizeof(mCurrentFrame.isFBComposed)); |
| 526 | mCurrentFrame.needsRedraw = true; |
| 527 | } |
| 528 | |
| 529 | void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) { |
| 530 | |
| 531 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
| 532 | for(int index = 0;index < nYuvCount; index++){ |
| 533 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
| 534 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
| 535 | |
| 536 | if(!isYUVDoable(ctx, layer)) { |
| 537 | if(!mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 538 | mCurrentFrame.isFBComposed[nYuvIndex] = true; |
| 539 | mCurrentFrame.fbCount++; |
| 540 | } |
| 541 | } else { |
| 542 | if(mCurrentFrame.isFBComposed[nYuvIndex]) { |
| 543 | mCurrentFrame.isFBComposed[nYuvIndex] = false; |
| 544 | mCurrentFrame.fbCount--; |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, |
| 549 | mCurrentFrame.fbCount); |
| 550 | } |
| 551 | |
| 552 | int MDPComp::programMDP(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 553 | int fbZOrder = -1; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 554 | |
| 555 | if(!allocLayerPipes(ctx, list)) { |
| 556 | ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__); |
| 557 | goto fn_exit; |
| 558 | } |
| 559 | |
| 560 | for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount; |
| 561 | index++) { |
| 562 | if(!mCurrentFrame.isFBComposed[index]) { |
| 563 | |
| 564 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 565 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 566 | |
| 567 | MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 568 | cur_pipe->zOrder = mdpNextZOrder++; |
| 569 | |
| 570 | if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){ |
| 571 | ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \ |
| 572 | layer %d",__FUNCTION__, index); |
| 573 | goto fn_exit; |
| 574 | } |
| 575 | } else if(fbZOrder < 0) { |
| 576 | fbZOrder = mdpNextZOrder++; |
| 577 | }; |
| 578 | } |
| 579 | |
| 580 | return fbZOrder; |
| 581 | |
| 582 | fn_exit: |
| 583 | //Complete fallback to FB |
| 584 | resetFrameForFB(ctx, list); |
| 585 | return 0; |
| 586 | } |
| 587 | |
| 588 | 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] | 589 | |
| 590 | //reset old data |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 591 | mCurrentFrame.reset(); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 592 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 593 | if(!isFrameDoable(ctx)) { |
| 594 | ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame", |
| 595 | __FUNCTION__); |
| 596 | return 0; |
| 597 | } |
| 598 | |
| 599 | mCurrentFrame.layerCount = ctx->listStats[mDpy].numAppLayers; |
| 600 | |
| 601 | //Iterate layer list for cached layers |
| 602 | updateLayerCache(ctx, list); |
| 603 | |
| 604 | //Add YUV layers to cached list |
| 605 | updateYUV(ctx, list); |
| 606 | |
| 607 | //Optimze for bypass |
| 608 | batchLayers(); |
| 609 | |
| 610 | //list is already parsed / batched for optimal mixed mode composition. |
| 611 | //Check whether layers marked for MDP Composition is actually doable. |
| 612 | if(!isFullFrameDoable(ctx, list)){ |
| 613 | //All layers marked for MDP comp cannot be bypassed. |
| 614 | //Try to compose atleast YUV layers through MDP comp and let |
| 615 | //all the RGB layers compose in FB |
| 616 | resetFrameForFB(ctx, list); |
| 617 | updateYUV(ctx, list); |
| 618 | } |
| 619 | |
| 620 | mCurrentFrame.mdpCount = mCurrentFrame.layerCount - |
| 621 | mCurrentFrame.fbCount; |
| 622 | |
| 623 | if(mCurrentFrame.mdpCount) { |
| 624 | // populate layer and MDP maps |
| 625 | for(int idx = 0, mdpIdx = 0; idx < mCurrentFrame.layerCount; idx++) { |
| 626 | if(!mCurrentFrame.isFBComposed[idx]) { |
| 627 | mCurrentFrame.mdpToLayer[mdpIdx].listIndex = idx; |
| 628 | mCurrentFrame.layerToMDP[idx] = mdpIdx++; |
| 629 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 630 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 631 | //Acquire and Program MDP pipes |
| 632 | mCurrentFrame.fbZ = programMDP(ctx, list); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 633 | } |
| 634 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 635 | /* Any change in composition types needs an FB refresh*/ |
| 636 | if(mCurrentFrame.fbCount && |
| 637 | ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) || |
| 638 | (mCurrentFrame.fbCount != mCachedFrame.cacheCount) || |
| 639 | !mCurrentFrame.mdpCount)) { |
| 640 | mCurrentFrame.needsRedraw = true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 641 | } |
| 642 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 643 | //UpdateLayerFlags |
| 644 | setMDPCompLayerFlags(ctx, list); |
| 645 | |
| 646 | if(isDebug()) { |
| 647 | android::String8 sDump(""); |
| 648 | dump(sDump); |
| 649 | ALOGE("%s",sDump.string()); |
| 650 | } |
| 651 | |
| 652 | return mCurrentFrame.fbZ; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | //=============MDPCompLowRes=================================================== |
| 656 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 657 | /* |
| 658 | * Configures pipe(s) for MDP composition |
| 659 | */ |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 660 | int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 661 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 662 | MdpPipeInfoLowRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 663 | *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 664 | eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION; |
| 665 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 666 | eIsFg isFg = IS_FG_OFF; |
| 667 | eDest dest = mdp_info.index; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 668 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 669 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d", |
| 670 | __FUNCTION__, layer, zOrder, dest); |
| 671 | |
| 672 | return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest, |
| 673 | &PipeLayerPair.rot); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 674 | } |
| 675 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 676 | int MDPCompLowRes::pipesNeeded(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 677 | hwc_display_contents_1_t* list) { |
| 678 | return mCurrentFrame.mdpCount; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 679 | } |
| 680 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 681 | bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 682 | hwc_display_contents_1_t* list) { |
| 683 | if(isYuvPresent(ctx, mDpy)) { |
| 684 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 685 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 686 | for(int index = 0; index < nYuvCount ; index ++) { |
| 687 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 688 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 689 | if(mCurrentFrame.isFBComposed[nYuvIndex]) |
| 690 | continue; |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 691 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 692 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 693 | |
| 694 | int mdpIndex = mCurrentFrame.layerToMDP[nYuvIndex]; |
| 695 | |
| 696 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 697 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 698 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 699 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 700 | |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 701 | pipe_info.index = getMdpPipe(ctx, MDPCOMP_OV_VG); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 702 | if(pipe_info.index == ovutils::OV_INVALID) { |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 703 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for Videos", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 704 | __FUNCTION__); |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 705 | return false; |
| 706 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 707 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 708 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 709 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 710 | for(int index = 0 ; index < mCurrentFrame.layerCount; index++ ) { |
| 711 | if(mCurrentFrame.isFBComposed[index]) continue; |
Jeykumar Sankaran | cf53700 | 2013-01-21 21:19:15 -0800 | [diff] [blame] | 712 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 713 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 714 | |
| 715 | if(isYuvBuffer(hnd)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 716 | continue; |
| 717 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 718 | int mdpIndex = mCurrentFrame.layerToMDP[index]; |
| 719 | |
| 720 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 721 | info.pipeInfo = new MdpPipeInfoLowRes; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 722 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 723 | MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo; |
| 724 | |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 725 | ePipeType type = MDPCOMP_OV_ANY; |
| 726 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 727 | if(!qhwc::needsScaling(layer) |
| 728 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 729 | && ctx->mMDP.version >= qdutils::MDSS_V5) { |
Jeykumar Sankaran | a37fdbf | 2013-03-06 18:59:28 -0800 | [diff] [blame] | 730 | type = MDPCOMP_OV_DMA; |
| 731 | } |
| 732 | |
| 733 | pipe_info.index = getMdpPipe(ctx, type); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 734 | if(pipe_info.index == ovutils::OV_INVALID) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 735 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 736 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 737 | } |
| 738 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 739 | return true; |
| 740 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 741 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 742 | 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] | 743 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 744 | if(!isEnabled()) { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 745 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 746 | return true; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 747 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 748 | |
| 749 | if(!ctx || !list) { |
| 750 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 751 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 752 | } |
| 753 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 754 | /* reset Invalidator */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 755 | if(idleInvalidator && mCurrentFrame.mdpCount) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 756 | idleInvalidator->markForSleep(); |
| 757 | |
| 758 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 759 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 760 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 761 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 762 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 763 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 764 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 765 | |
Naseer Ahmed | 5b6708a | 2012-08-02 13:46:08 -0700 | [diff] [blame] | 766 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 767 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 768 | if(!hnd) { |
| 769 | ALOGE("%s handle null", __FUNCTION__); |
| 770 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 773 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 774 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 775 | MdpPipeInfoLowRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 776 | *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 777 | ovutils::eDest dest = pipe_info.index; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 778 | if(dest == ovutils::OV_INVALID) { |
| 779 | ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest); |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 780 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 783 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 784 | continue; |
| 785 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 786 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 787 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 788 | using pipe: %d", __FUNCTION__, layer, |
| 789 | hnd, dest ); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 790 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 791 | int fd = hnd->fd; |
| 792 | uint32_t offset = hnd->offset; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 793 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 794 | if(rot) { |
| 795 | if(!rot->queueBuffer(fd, offset)) |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 796 | return false; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 797 | fd = rot->getDstMemId(); |
| 798 | offset = rot->getDstOffset(); |
| 799 | } |
| 800 | |
| 801 | if (!ov.queueBuffer(fd, offset, dest)) { |
| 802 | ALOGE("%s: queueBuffer failed for external", __FUNCTION__); |
| 803 | return false; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 804 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 805 | |
| 806 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 807 | } |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 808 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 809 | } |
| 810 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 811 | //=============MDPCompHighRes=================================================== |
| 812 | |
| 813 | int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 814 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 815 | int pipesNeeded = 0; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 816 | int hw_w = ctx->dpyAttr[mDpy].xres; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 817 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 818 | for(int i = 0; i < mCurrentFrame.layerCount; ++i) { |
| 819 | if(!mCurrentFrame.isFBComposed[i]) { |
| 820 | hwc_layer_1_t* layer = &list->hwLayers[i]; |
| 821 | hwc_rect_t dst = layer->displayFrame; |
| 822 | if(dst.left > hw_w/2) { |
| 823 | pipesNeeded++; |
| 824 | } else if(dst.right <= hw_w/2) { |
| 825 | pipesNeeded++; |
| 826 | } else { |
| 827 | pipesNeeded += 2; |
| 828 | } |
| 829 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 830 | } |
| 831 | return pipesNeeded; |
| 832 | } |
| 833 | |
| 834 | bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 835 | MdpPipeInfoHighRes& pipe_info, |
| 836 | ePipeType type) { |
| 837 | int hw_w = ctx->dpyAttr[mDpy].xres; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 838 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 839 | hwc_rect_t dst = layer->displayFrame; |
| 840 | if(dst.left > hw_w/2) { |
| 841 | pipe_info.lIndex = ovutils::OV_INVALID; |
| 842 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 843 | if(pipe_info.rIndex == ovutils::OV_INVALID) |
| 844 | return false; |
| 845 | } else if (dst.right <= hw_w/2) { |
| 846 | pipe_info.rIndex = ovutils::OV_INVALID; |
| 847 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 848 | if(pipe_info.lIndex == ovutils::OV_INVALID) |
| 849 | return false; |
| 850 | } else { |
| 851 | pipe_info.rIndex = getMdpPipe(ctx, type); |
| 852 | pipe_info.lIndex = getMdpPipe(ctx, type); |
| 853 | if(pipe_info.rIndex == ovutils::OV_INVALID || |
| 854 | pipe_info.lIndex == ovutils::OV_INVALID) |
| 855 | return false; |
| 856 | } |
| 857 | return true; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 861 | hwc_display_contents_1_t* list) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 862 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 863 | int layer_count = ctx->listStats[mDpy].numAppLayers; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 864 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 865 | if(isYuvPresent(ctx, mDpy)) { |
| 866 | int nYuvCount = ctx->listStats[mDpy].yuvCount; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 867 | |
| 868 | for(int index = 0; index < nYuvCount; index ++) { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 869 | int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 870 | hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex]; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 871 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[nYuvIndex]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 872 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 873 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 874 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 875 | if(!acquireMDPPipes(ctx, layer, pipe_info,MDPCOMP_OV_VG)) { |
| 876 | ALOGD_IF(isDebug(),"%s: Unable to get pipe for videos", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 877 | __FUNCTION__); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 878 | //TODO: windback pipebook data on fail |
| 879 | return false; |
| 880 | } |
| 881 | pipe_info.zOrder = nYuvIndex; |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | for(int index = 0 ; index < layer_count ; index++ ) { |
| 886 | hwc_layer_1_t* layer = &list->hwLayers[index]; |
| 887 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 888 | |
| 889 | if(isYuvBuffer(hnd)) |
| 890 | continue; |
| 891 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 892 | PipeLayerPair& info = mCurrentFrame.mdpToLayer[index]; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 893 | info.pipeInfo = new MdpPipeInfoHighRes; |
Saurabh Shah | 9e3adb2 | 2013-03-26 11:16:27 -0700 | [diff] [blame] | 894 | info.rot = NULL; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 895 | MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo; |
| 896 | |
| 897 | ePipeType type = MDPCOMP_OV_ANY; |
| 898 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 899 | if(!qhwc::needsScaling(layer) |
| 900 | && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE |
| 901 | && ctx->mMDP.version >= qdutils::MDSS_V5) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 902 | type = MDPCOMP_OV_DMA; |
| 903 | |
| 904 | if(!acquireMDPPipes(ctx, layer, pipe_info, type)) { |
| 905 | ALOGD_IF(isDebug(), "%s: Unable to get pipe for UI", __FUNCTION__); |
| 906 | //TODO: windback pipebook data on fail |
| 907 | return false; |
| 908 | } |
| 909 | pipe_info.zOrder = index; |
| 910 | } |
| 911 | return true; |
| 912 | } |
| 913 | /* |
| 914 | * Configures pipe(s) for MDP composition |
| 915 | */ |
| 916 | int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 917 | PipeLayerPair& PipeLayerPair) { |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 918 | MdpPipeInfoHighRes& mdp_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 919 | *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo)); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 920 | eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder); |
| 921 | eIsFg isFg = IS_FG_OFF; |
| 922 | eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION; |
| 923 | eDest lDest = mdp_info.lIndex; |
| 924 | eDest rDest = mdp_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 925 | |
| 926 | ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d" |
| 927 | "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest); |
| 928 | |
| 929 | return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest, |
| 930 | rDest, &PipeLayerPair.rot); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) { |
| 934 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 935 | if(!isEnabled()) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 936 | ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__); |
| 937 | return true; |
| 938 | } |
| 939 | |
| 940 | if(!ctx || !list) { |
| 941 | ALOGE("%s: invalid contxt or list",__FUNCTION__); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 942 | return false; |
| 943 | } |
| 944 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 945 | /* reset Invalidator */ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 946 | if(idleInvalidator && mCurrentFrame.mdpCount) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 947 | idleInvalidator->markForSleep(); |
| 948 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 949 | overlay::Overlay& ov = *ctx->mOverlay; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 950 | LayerProp *layerProp = ctx->layerProp[mDpy]; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 951 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 952 | int numHwLayers = ctx->listStats[mDpy].numAppLayers; |
| 953 | for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ ) |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 954 | { |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 955 | if(mCurrentFrame.isFBComposed[i]) continue; |
| 956 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 957 | hwc_layer_1_t *layer = &list->hwLayers[i]; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 958 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
| 959 | if(!hnd) { |
| 960 | ALOGE("%s handle null", __FUNCTION__); |
| 961 | return false; |
| 962 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 963 | |
| 964 | if(!(layerProp[i].mFlags & HWC_MDPCOMP)) { |
| 965 | continue; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 966 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 967 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 968 | int mdpIndex = mCurrentFrame.layerToMDP[i]; |
| 969 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 970 | MdpPipeInfoHighRes& pipe_info = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 971 | *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo; |
| 972 | Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 973 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 974 | ovutils::eDest indexL = pipe_info.lIndex; |
| 975 | ovutils::eDest indexR = pipe_info.rIndex; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 976 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 977 | int fd = hnd->fd; |
| 978 | int offset = hnd->offset; |
| 979 | |
| 980 | if(rot) { |
| 981 | rot->queueBuffer(fd, offset); |
| 982 | fd = rot->getDstMemId(); |
| 983 | offset = rot->getDstOffset(); |
| 984 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 985 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 986 | //************* play left mixer ********** |
| 987 | if(indexL != ovutils::OV_INVALID) { |
| 988 | ovutils::eDest destL = (ovutils::eDest)indexL; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 989 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 990 | using pipe: %d", __FUNCTION__, layer, hnd, indexL ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 991 | if (!ov.queueBuffer(fd, offset, destL)) { |
| 992 | ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__); |
| 993 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 994 | } |
| 995 | } |
| 996 | |
| 997 | //************* play right mixer ********** |
| 998 | if(indexR != ovutils::OV_INVALID) { |
| 999 | ovutils::eDest destR = (ovutils::eDest)indexR; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1000 | ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \ |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 1001 | using pipe: %d", __FUNCTION__, layer, hnd, indexR ); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1002 | if (!ov.queueBuffer(fd, offset, destR)) { |
| 1003 | ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__); |
| 1004 | return false; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1005 | } |
| 1006 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1007 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1008 | layerProp[i].mFlags &= ~HWC_MDPCOMP; |
| 1009 | } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 1010 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 1011 | return true; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1012 | } |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1013 | }; //namespace |
| 1014 | |