blob: 2ab9491add65e56e375afb3075a03ef5fedb0f52 [file] [log] [blame]
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001/*
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08002 * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
Naseer Ahmed7c958d42012-07-31 18:57:03 -07003 * 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
Saurabh Shah4fdde762013-04-30 18:47:33 -070019#include <math.h>
Naseer Ahmed7c958d42012-07-31 18:57:03 -070020#include "hwc_mdpcomp.h"
Naseer Ahmed54821fe2012-11-28 18:44:38 -050021#include <sys/ioctl.h>
Saurabh Shah56f610d2012-08-07 15:27:06 -070022#include "external.h"
Ramkumar Radhakrishnan47573e22012-11-07 11:36:41 -080023#include "qdMetaData.h"
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080024#include "mdp_version.h"
Saurabh Shahacf10202013-02-26 10:15:15 -080025#include <overlayRotator.h>
26
Saurabh Shah85234ec2013-04-12 17:09:00 -070027using namespace overlay;
Saurabh Shahbd2d0832013-04-04 14:33:08 -070028using namespace qdutils;
Saurabh Shahacf10202013-02-26 10:15:15 -080029using namespace overlay::utils;
30namespace ovutils = overlay::utils;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070031
Naseer Ahmed7c958d42012-07-31 18:57:03 -070032namespace qhwc {
33
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080034//==============MDPComp========================================================
35
Naseer Ahmed7c958d42012-07-31 18:57:03 -070036IdleInvalidator *MDPComp::idleInvalidator = NULL;
37bool MDPComp::sIdleFallBack = false;
38bool MDPComp::sDebugLogs = false;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050039bool MDPComp::sEnabled = false;
Jeykumar Sankaran24c199d2013-05-24 09:40:36 -070040bool MDPComp::sEnableMixedMode = true;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080041int MDPComp::sMaxPipesPerMixer = MAX_PIPES_PER_MIXER;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070042
Saurabh Shah67a38c32013-06-10 16:23:15 -070043MDPComp* MDPComp::getObject(const int& width, const int& rightSplit,
44 const int& dpy) {
45 if(width > MAX_DISPLAY_DIM || rightSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080046 return new MDPCompHighRes(dpy);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080047 }
Saurabh Shah67a38c32013-06-10 16:23:15 -070048 return new MDPCompLowRes(dpy);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080049}
50
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080051MDPComp::MDPComp(int dpy):mDpy(dpy){};
52
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080053void MDPComp::dump(android::String8& buf)
54{
Prabhanjan Kandula088bd892013-07-02 23:47:13 +053055 Locker::Autolock _l(mMdpCompLock);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080056 dumpsys_log(buf,"HWC Map for Dpy: %s \n",
57 mDpy ? "\"EXTERNAL\"" : "\"PRIMARY\"");
58 dumpsys_log(buf,"PREV_FRAME: layerCount:%2d mdpCount:%2d \
59 cacheCount:%2d \n", mCachedFrame.layerCount,
60 mCachedFrame.mdpCount, mCachedFrame.cacheCount);
61 dumpsys_log(buf,"CURR_FRAME: layerCount:%2d mdpCount:%2d \
62 fbCount:%2d \n", mCurrentFrame.layerCount,
63 mCurrentFrame.mdpCount, mCurrentFrame.fbCount);
64 dumpsys_log(buf,"needsFBRedraw:%3s pipesUsed:%2d MaxPipesPerMixer: %d \n",
65 (mCurrentFrame.needsRedraw? "YES" : "NO"),
66 mCurrentFrame.mdpCount, sMaxPipesPerMixer);
67 dumpsys_log(buf," --------------------------------------------- \n");
68 dumpsys_log(buf," listIdx | cached? | mdpIndex | comptype | Z \n");
69 dumpsys_log(buf," --------------------------------------------- \n");
70 for(int index = 0; index < mCurrentFrame.layerCount; index++ )
71 dumpsys_log(buf," %7d | %7s | %8d | %9s | %2d \n",
72 index,
73 (mCurrentFrame.isFBComposed[index] ? "YES" : "NO"),
74 mCurrentFrame.layerToMDP[index],
75 (mCurrentFrame.isFBComposed[index] ?
76 (mCurrentFrame.needsRedraw ? "GLES" : "CACHE") : "MDP"),
77 (mCurrentFrame.isFBComposed[index] ? mCurrentFrame.fbZ :
78 mCurrentFrame.mdpToLayer[mCurrentFrame.layerToMDP[index]].pipeInfo->zOrder));
79 dumpsys_log(buf,"\n");
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080080}
81
82bool MDPComp::init(hwc_context_t *ctx) {
83
84 if(!ctx) {
85 ALOGE("%s: Invalid hwc context!!",__FUNCTION__);
86 return false;
87 }
88
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080089 char property[PROPERTY_VALUE_MAX];
90
91 sEnabled = false;
92 if((property_get("persist.hwc.mdpcomp.enable", property, NULL) > 0) &&
Jeykumar Sankaran85977e32013-02-25 17:06:08 -080093 (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
94 (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080095 sEnabled = true;
Xiaoming Zhou944e02e2013-05-01 20:54:03 -040096 if(!setupBasePipe(ctx)) {
97 ALOGE("%s: Failed to setup primary base pipe", __FUNCTION__);
98 return false;
99 }
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800100 }
101
Jeykumar Sankaran24c199d2013-05-24 09:40:36 -0700102 sEnableMixedMode = true;
103 if((property_get("debug.mdpcomp.mixedmode.disable", property, NULL) > 0) &&
104 (!strncmp(property, "1", PROPERTY_VALUE_MAX ) ||
105 (!strncasecmp(property,"true", PROPERTY_VALUE_MAX )))) {
106 sEnableMixedMode = false;
107 }
108
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800109 sDebugLogs = false;
110 if(property_get("debug.mdpcomp.logs", property, NULL) > 0) {
111 if(atoi(property) != 0)
112 sDebugLogs = true;
113 }
114
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800115 sMaxPipesPerMixer = MAX_PIPES_PER_MIXER;
Saurabh Shah85234ec2013-04-12 17:09:00 -0700116 if(property_get("debug.mdpcomp.maxpermixer", property, "-1") > 0) {
117 int val = atoi(property);
118 if(val >= 0)
119 sMaxPipesPerMixer = min(val, MAX_PIPES_PER_MIXER);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800120 }
121
Zohaib Alamd9743242013-07-19 16:07:34 -0400122 long idle_timeout = DEFAULT_IDLE_TIME;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800123 if(property_get("debug.mdpcomp.idletime", property, NULL) > 0) {
124 if(atoi(property) != 0)
125 idle_timeout = atoi(property);
126 }
127
Zohaib Alamd9743242013-07-19 16:07:34 -0400128 //create Idle Invalidator only when not disabled through property
129 if(idle_timeout != -1)
130 idleInvalidator = IdleInvalidator::getInstance();
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800131
132 if(idleInvalidator == NULL) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800133 ALOGE("%s: failed to instantiate idleInvalidator object", __FUNCTION__);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800134 } else {
135 idleInvalidator->init(timeout_handler, ctx, idle_timeout);
136 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700137 return true;
138}
139
140void MDPComp::timeout_handler(void *udata) {
141 struct hwc_context_t* ctx = (struct hwc_context_t*)(udata);
142
143 if(!ctx) {
144 ALOGE("%s: received empty data in timer callback", __FUNCTION__);
145 return;
146 }
147
Jesse Hall3be78d92012-08-21 15:12:23 -0700148 if(!ctx->proc) {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700149 ALOGE("%s: HWC proc not registered", __FUNCTION__);
150 return;
151 }
152 sIdleFallBack = true;
153 /* Trigger SF to redraw the current frame */
Jesse Hall3be78d92012-08-21 15:12:23 -0700154 ctx->proc->invalidate(ctx->proc);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700155}
156
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800157void MDPComp::setMDPCompLayerFlags(hwc_context_t *ctx,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800158 hwc_display_contents_1_t* list) {
159 LayerProp *layerProp = ctx->layerProp[mDpy];
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800160
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800161 for(int index = 0; index < ctx->listStats[mDpy].numAppLayers; index++) {
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800162 hwc_layer_1_t* layer = &(list->hwLayers[index]);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800163 if(!mCurrentFrame.isFBComposed[index]) {
164 layerProp[index].mFlags |= HWC_MDPCOMP;
165 layer->compositionType = HWC_OVERLAY;
166 layer->hints |= HWC_HINT_CLEAR_FB;
167 mCachedFrame.hnd[index] = NULL;
168 } else {
169 if(!mCurrentFrame.needsRedraw)
170 layer->compositionType = HWC_OVERLAY;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800171 }
172 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700173}
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500174
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800175/*
176 * Sets up BORDERFILL as default base pipe and detaches RGB0.
177 * Framebuffer is always updated using PLAY ioctl.
178 */
179bool MDPComp::setupBasePipe(hwc_context_t *ctx) {
180 const int dpy = HWC_DISPLAY_PRIMARY;
181 int fb_stride = ctx->dpyAttr[dpy].stride;
182 int fb_width = ctx->dpyAttr[dpy].xres;
183 int fb_height = ctx->dpyAttr[dpy].yres;
184 int fb_fd = ctx->dpyAttr[dpy].fd;
185
186 mdp_overlay ovInfo;
187 msmfb_overlay_data ovData;
188 memset(&ovInfo, 0, sizeof(mdp_overlay));
189 memset(&ovData, 0, sizeof(msmfb_overlay_data));
190
191 ovInfo.src.format = MDP_RGB_BORDERFILL;
192 ovInfo.src.width = fb_width;
193 ovInfo.src.height = fb_height;
194 ovInfo.src_rect.w = fb_width;
195 ovInfo.src_rect.h = fb_height;
196 ovInfo.dst_rect.w = fb_width;
197 ovInfo.dst_rect.h = fb_height;
198 ovInfo.id = MSMFB_NEW_REQUEST;
199
200 if (ioctl(fb_fd, MSMFB_OVERLAY_SET, &ovInfo) < 0) {
201 ALOGE("Failed to call ioctl MSMFB_OVERLAY_SET err=%s",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800202 strerror(errno));
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800203 return false;
204 }
205
206 ovData.id = ovInfo.id;
207 if (ioctl(fb_fd, MSMFB_OVERLAY_PLAY, &ovData) < 0) {
208 ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY err=%s",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800209 strerror(errno));
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800210 return false;
211 }
212 return true;
213}
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800214MDPComp::FrameInfo::FrameInfo() {
Saurabh Shahaa236822013-04-24 18:07:26 -0700215 reset(0);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800216}
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800217
Saurabh Shahaa236822013-04-24 18:07:26 -0700218void MDPComp::FrameInfo::reset(const int& numLayers) {
219 for(int i = 0 ; i < MAX_PIPES_PER_MIXER && numLayers; i++ ) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800220 if(mdpToLayer[i].pipeInfo) {
221 delete mdpToLayer[i].pipeInfo;
222 mdpToLayer[i].pipeInfo = NULL;
223 //We dont own the rotator
224 mdpToLayer[i].rot = NULL;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800225 }
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800226 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800227
228 memset(&mdpToLayer, 0, sizeof(mdpToLayer));
229 memset(&layerToMDP, -1, sizeof(layerToMDP));
Saurabh Shahaa236822013-04-24 18:07:26 -0700230 memset(&isFBComposed, 1, sizeof(isFBComposed));
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800231
Saurabh Shahaa236822013-04-24 18:07:26 -0700232 layerCount = numLayers;
233 fbCount = numLayers;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800234 mdpCount = 0;
Saurabh Shah2f3895f2013-05-02 10:13:31 -0700235 needsRedraw = true;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800236 fbZ = 0;
237}
238
Saurabh Shahaa236822013-04-24 18:07:26 -0700239void MDPComp::FrameInfo::map() {
240 // populate layer and MDP maps
241 int mdpIdx = 0;
242 for(int idx = 0; idx < layerCount; idx++) {
243 if(!isFBComposed[idx]) {
244 mdpToLayer[mdpIdx].listIndex = idx;
245 layerToMDP[idx] = mdpIdx++;
246 }
247 }
248}
249
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800250MDPComp::LayerCache::LayerCache() {
251 reset();
252}
253
254void MDPComp::LayerCache::reset() {
Saurabh Shahaa236822013-04-24 18:07:26 -0700255 memset(&hnd, 0, sizeof(hnd));
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800256 mdpCount = 0;
257 cacheCount = 0;
258 layerCount = 0;
Saurabh Shahaa236822013-04-24 18:07:26 -0700259 fbZ = -1;
260}
261
262void MDPComp::LayerCache::cacheAll(hwc_display_contents_1_t* list) {
263 const int numAppLayers = list->numHwLayers - 1;
264 for(int i = 0; i < numAppLayers; i++) {
265 hnd[i] = list->hwLayers[i].handle;
266 }
267}
268
269void MDPComp::LayerCache::updateCounts(const FrameInfo& curFrame) {
270 mdpCount = curFrame.mdpCount;
271 cacheCount = curFrame.fbCount;
272 layerCount = curFrame.layerCount;
273 fbZ = curFrame.fbZ;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800274}
275
Sravan Kumar D.V.Nad5d9292013-04-24 14:23:04 +0530276bool MDPComp::isValidDimension(hwc_context_t *ctx, hwc_layer_1_t *layer) {
Saurabh Shah4fdde762013-04-30 18:47:33 -0700277 const int dpy = HWC_DISPLAY_PRIMARY;
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800278 private_handle_t *hnd = (private_handle_t *)layer->handle;
279
280 if(!hnd) {
281 ALOGE("%s: layer handle is NULL", __FUNCTION__);
282 return false;
283 }
284
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800285 int hw_w = ctx->dpyAttr[mDpy].xres;
286 int hw_h = ctx->dpyAttr[mDpy].yres;
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800287
Saurabh Shah4fdde762013-04-30 18:47:33 -0700288 hwc_rect_t crop = layer->sourceCrop;
289 hwc_rect_t dst = layer->displayFrame;
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800290
291 if(dst.left < 0 || dst.top < 0 || dst.right > hw_w || dst.bottom > hw_h) {
Saurabh Shah4fdde762013-04-30 18:47:33 -0700292 hwc_rect_t scissor = {0, 0, hw_w, hw_h };
293 qhwc::calculate_crop_rects(crop, dst, scissor, layer->transform);
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800294 }
295
Saurabh Shah4fdde762013-04-30 18:47:33 -0700296 int crop_w = crop.right - crop.left;
297 int crop_h = crop.bottom - crop.top;
298 int dst_w = dst.right - dst.left;
299 int dst_h = dst.bottom - dst.top;
300 float w_dscale = ceilf((float)crop_w / (float)dst_w);
301 float h_dscale = ceilf((float)crop_h / (float)dst_h);
302
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800303 /* Workaround for MDP HW limitation in DSI command mode panels where
304 * FPS will not go beyond 30 if buffers on RGB pipes are of width or height
305 * less than 5 pixels
Sravan Kumar D.V.Nad5d9292013-04-24 14:23:04 +0530306 * There also is a HW limilation in MDP, minimum block size is 2x2
307 * Fallback to GPU if height is less than 2.
308 */
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800309 if((crop_w < 5)||(crop_h < 5))
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800310 return false;
311
Saurabh Shah4fdde762013-04-30 18:47:33 -0700312 const uint32_t downscale =
313 qdutils::MDPVersion::getInstance().getMaxMDPDownscale();
314 if(ctx->mMDP.version >= qdutils::MDSS_V5) {
315 /* Workaround for downscales larger than 4x.
316 * Will be removed once decimator block is enabled for MDSS
317 */
318 if(!qdutils::MDPVersion::getInstance().supportsDecimation()) {
319 if(crop_w > MAX_DISPLAY_DIM || w_dscale > downscale ||
320 h_dscale > downscale)
321 return false;
322 } else {
323 if(w_dscale > 64 || h_dscale > 64)
324 return false;
325 }
326 } else { //A-family
327 if(w_dscale > downscale || h_dscale > downscale)
328 return false;
329 }
330
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800331 return true;
332}
333
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800334ovutils::eDest MDPComp::getMdpPipe(hwc_context_t *ctx, ePipeType type) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800335 overlay::Overlay& ov = *ctx->mOverlay;
336 ovutils::eDest mdp_pipe = ovutils::OV_INVALID;
337
338 switch(type) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800339 case MDPCOMP_OV_DMA:
340 mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_DMA, mDpy);
341 if(mdp_pipe != ovutils::OV_INVALID) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800342 return mdp_pipe;
343 }
344 case MDPCOMP_OV_ANY:
345 case MDPCOMP_OV_RGB:
346 mdp_pipe = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy);
347 if(mdp_pipe != ovutils::OV_INVALID) {
348 return mdp_pipe;
349 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800350
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800351 if(type == MDPCOMP_OV_RGB) {
352 //Requested only for RGB pipe
353 break;
354 }
355 case MDPCOMP_OV_VG:
356 return ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy);
357 default:
358 ALOGE("%s: Invalid pipe type",__FUNCTION__);
359 return ovutils::OV_INVALID;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800360 };
361 return ovutils::OV_INVALID;
362}
363
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800364bool MDPComp::isFrameDoable(hwc_context_t *ctx) {
Saurabh Shahaa236822013-04-24 18:07:26 -0700365 bool ret = true;
Jeykumar Sankaran24c199d2013-05-24 09:40:36 -0700366 const int numAppLayers = ctx->listStats[mDpy].numAppLayers;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800367
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800368 if(!isEnabled()) {
369 ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__);
Saurabh Shahaa236822013-04-24 18:07:26 -0700370 ret = false;
Saurabh Shahd4e65852013-06-17 11:33:53 -0700371 } else if(qdutils::MDPVersion::getInstance().is8x26() &&
372 ctx->mVideoTransFlag &&
373 ctx->mExtDisplay->isExternalConnected()) {
374 //1 Padding round to shift pipes across mixers
375 ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round",
376 __FUNCTION__);
377 ret = false;
Saurabh Shahaa236822013-04-24 18:07:26 -0700378 } else if(ctx->mExtDispConfiguring) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800379 ALOGD_IF( isDebug(),"%s: External Display connection is pending",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800380 __FUNCTION__);
Saurabh Shahaa236822013-04-24 18:07:26 -0700381 ret = false;
Saurabh Shahaa236822013-04-24 18:07:26 -0700382 } else if(ctx->isPaddingRound) {
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700383 ctx->isPaddingRound = false;
384 ALOGD_IF(isDebug(), "%s: padding round",__FUNCTION__);
Saurabh Shahaa236822013-04-24 18:07:26 -0700385 ret = false;
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700386 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700387 return ret;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800388}
389
390/* Checks for conditions where all the layers marked for MDP comp cannot be
391 * bypassed. On such conditions we try to bypass atleast YUV layers */
392bool MDPComp::isFullFrameDoable(hwc_context_t *ctx,
393 hwc_display_contents_1_t* list){
394
Saurabh Shahaa236822013-04-24 18:07:26 -0700395 const int numAppLayers = ctx->listStats[mDpy].numAppLayers;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800396
Saurabh Shah2d998a92013-05-14 17:55:58 -0700397 if(sIdleFallBack) {
398 ALOGD_IF(isDebug(), "%s: Idle fallback dpy %d",__FUNCTION__, mDpy);
399 return false;
400 }
401
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800402 if(mDpy > HWC_DISPLAY_PRIMARY){
403 ALOGD_IF(isDebug(), "%s: Cannot support External display(s)",
404 __FUNCTION__);
405 return false;
406 }
407
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800408 if(isSkipPresent(ctx, mDpy)) {
Saurabh Shahaa236822013-04-24 18:07:26 -0700409 ALOGD_IF(isDebug(),"%s: SKIP present: %d",
410 __FUNCTION__,
411 isSkipPresent(ctx, mDpy));
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800412 return false;
413 }
414
Saurabh Shah9f084ad2013-05-02 11:28:09 -0700415 if(ctx->listStats[mDpy].needsAlphaScale
416 && ctx->mMDP.version < qdutils::MDSS_V5) {
417 ALOGD_IF(isDebug(), "%s: frame needs alpha downscaling",__FUNCTION__);
418 return false;
419 }
420
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800421 //MDP composition is not efficient if layer needs rotator.
422 for(int i = 0; i < numAppLayers; ++i) {
423 // As MDP h/w supports flip operation, use MDP comp only for
424 // 180 transforms. Fail for any transform involving 90 (90, 270).
425 hwc_layer_1_t* layer = &list->hwLayers[i];
426 private_handle_t *hnd = (private_handle_t *)layer->handle;
Jeykumar Sankarana37fdbf2013-03-06 18:59:28 -0800427
Saurabh Shah4fdde762013-04-30 18:47:33 -0700428 if((layer->transform & HWC_TRANSFORM_ROT_90) && !isYuvBuffer(hnd)) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800429 ALOGD_IF(isDebug(), "%s: orientation involved",__FUNCTION__);
430 return false;
431 }
432
Saurabh Shah4fdde762013-04-30 18:47:33 -0700433 if(!isValidDimension(ctx,layer)) {
434 ALOGD_IF(isDebug(), "%s: Buffer is of invalid width",
435 __FUNCTION__);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800436 return false;
437 }
Prabhanjan Kandula9fb032a2013-06-18 17:37:22 +0530438
439 //For 8x26 with panel width>1k, if RGB layer needs HFLIP fail mdp comp
440 // may not need it if Gfx pre-rotation can handle all flips & rotations
441 if(qdutils::MDPVersion::getInstance().is8x26() &&
442 (ctx->dpyAttr[mDpy].xres > 1024) &&
443 (layer->transform & HWC_TRANSFORM_FLIP_H) &&
444 (!isYuvBuffer(hnd)))
445 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800446 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700447
448 //If all above hard conditions are met we can do full or partial MDP comp.
449 bool ret = false;
450 if(fullMDPComp(ctx, list)) {
451 ret = true;
Jeykumar Sankaran24c199d2013-05-24 09:40:36 -0700452 } else if(partialMDPComp(ctx, list)) {
Saurabh Shahaa236822013-04-24 18:07:26 -0700453 ret = true;
454 }
455 return ret;
456}
457
458bool MDPComp::fullMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
459 //Setup mCurrentFrame
460 mCurrentFrame.mdpCount = mCurrentFrame.layerCount;
461 mCurrentFrame.fbCount = 0;
462 mCurrentFrame.fbZ = -1;
463 memset(&mCurrentFrame.isFBComposed, 0, sizeof(mCurrentFrame.isFBComposed));
464
465 int mdpCount = mCurrentFrame.mdpCount;
466 if(mdpCount > sMaxPipesPerMixer) {
467 ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__);
468 return false;
469 }
470
471 int numPipesNeeded = pipesNeeded(ctx, list);
472 int availPipes = getAvailablePipes(ctx);
473
474 if(numPipesNeeded > availPipes) {
475 ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d",
476 __FUNCTION__, numPipesNeeded, availPipes);
477 return false;
478 }
479
480 return true;
481}
482
483bool MDPComp::partialMDPComp(hwc_context_t *ctx, hwc_display_contents_1_t* list)
484{
485 int numAppLayers = ctx->listStats[mDpy].numAppLayers;
Jeykumar Sankaran24c199d2013-05-24 09:40:36 -0700486
487 if(!sEnableMixedMode) {
488 //Mixed mode is disabled. No need to even try caching.
489 return false;
490 }
491
Saurabh Shahaa236822013-04-24 18:07:26 -0700492 //Setup mCurrentFrame
493 mCurrentFrame.reset(numAppLayers);
494 updateLayerCache(ctx, list);
495 updateYUV(ctx, list);
496 batchLayers(); //sets up fbZ also
497
498 int mdpCount = mCurrentFrame.mdpCount;
499 if(mdpCount > (sMaxPipesPerMixer - 1)) { // -1 since FB is used
500 ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__);
501 return false;
502 }
503
504 int numPipesNeeded = pipesNeeded(ctx, list);
505 int availPipes = getAvailablePipes(ctx);
506
507 if(numPipesNeeded > availPipes) {
508 ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d",
509 __FUNCTION__, numPipesNeeded, availPipes);
510 return false;
511 }
512
513 return true;
514}
515
516bool MDPComp::isOnlyVideoDoable(hwc_context_t *ctx,
517 hwc_display_contents_1_t* list){
518 int numAppLayers = ctx->listStats[mDpy].numAppLayers;
519 mCurrentFrame.reset(numAppLayers);
520 updateYUV(ctx, list);
Saurabh Shah4fdde762013-04-30 18:47:33 -0700521 int mdpCount = mCurrentFrame.mdpCount;
Saurabh Shahaa236822013-04-24 18:07:26 -0700522 int fbNeeded = int(mCurrentFrame.fbCount != 0);
523
524 if(!isYuvPresent(ctx, mDpy)) {
525 return false;
526 }
527
Saurabh Shah4fdde762013-04-30 18:47:33 -0700528 if(!mdpCount)
529 return false;
530
Saurabh Shahaa236822013-04-24 18:07:26 -0700531 if(mdpCount > (sMaxPipesPerMixer - fbNeeded)) {
532 ALOGD_IF(isDebug(), "%s: Exceeds MAX_PIPES_PER_MIXER",__FUNCTION__);
533 return false;
534 }
535
536 int numPipesNeeded = pipesNeeded(ctx, list);
537 int availPipes = getAvailablePipes(ctx);
538 if(numPipesNeeded > availPipes) {
539 ALOGD_IF(isDebug(), "%s: Insufficient MDP pipes, needed %d, avail %d",
540 __FUNCTION__, numPipesNeeded, availPipes);
541 return false;
542 }
543
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800544 return true;
545}
546
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800547/* Checks for conditions where YUV layers cannot be bypassed */
548bool MDPComp::isYUVDoable(hwc_context_t* ctx, hwc_layer_1_t* layer) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700549 bool extAnimBlockFeature = mDpy && ctx->listStats[mDpy].isDisplayAnimating;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800550
Saurabh Shahe2474082013-05-15 16:32:13 -0700551 if(isSkipLayer(layer) && !extAnimBlockFeature) {
552 ALOGD_IF(isDebug(), "%s: Video marked SKIP dpy %d", __FUNCTION__, mDpy);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800553 return false;
554 }
555
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800556 if(isSecuring(ctx, layer)) {
557 ALOGD_IF(isDebug(), "%s: MDP securing is active", __FUNCTION__);
558 return false;
559 }
560
Saurabh Shah4fdde762013-04-30 18:47:33 -0700561 if(!isValidDimension(ctx, layer)) {
562 ALOGD_IF(isDebug(), "%s: Buffer is of invalid width",
563 __FUNCTION__);
564 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800565 }
Saurabh Shah4fdde762013-04-30 18:47:33 -0700566
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800567 return true;
568}
569
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800570void MDPComp::batchLayers() {
571 /* Idea is to keep as many contiguous non-updating(cached) layers in FB and
572 * send rest of them through MDP. NEVER mark an updating layer for caching.
573 * But cached ones can be marked for MDP*/
574
575 int maxBatchStart = -1;
576 int maxBatchCount = 0;
577
578 /* All or Nothing is cached. No batching needed */
Saurabh Shahaa236822013-04-24 18:07:26 -0700579 if(!mCurrentFrame.fbCount) {
580 mCurrentFrame.fbZ = -1;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800581 return;
Saurabh Shahaa236822013-04-24 18:07:26 -0700582 }
583 if(!mCurrentFrame.mdpCount) {
584 mCurrentFrame.fbZ = 0;
585 return;
586 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800587
588 /* Search for max number of contiguous (cached) layers */
589 int i = 0;
590 while (i < mCurrentFrame.layerCount) {
591 int count = 0;
592 while(mCurrentFrame.isFBComposed[i] && i < mCurrentFrame.layerCount) {
593 count++; i++;
594 }
595 if(count > maxBatchCount) {
596 maxBatchCount = count;
597 maxBatchStart = i - count;
Saurabh Shahaa236822013-04-24 18:07:26 -0700598 mCurrentFrame.fbZ = maxBatchStart;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800599 }
600 if(i < mCurrentFrame.layerCount) i++;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800601 }
602
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800603 /* reset rest of the layers for MDP comp */
604 for(int i = 0; i < mCurrentFrame.layerCount; i++) {
605 if(i != maxBatchStart){
606 mCurrentFrame.isFBComposed[i] = false;
607 } else {
608 i += maxBatchCount;
609 }
610 }
611
612 mCurrentFrame.fbCount = maxBatchCount;
Saurabh Shahaa236822013-04-24 18:07:26 -0700613 mCurrentFrame.mdpCount = mCurrentFrame.layerCount -
614 mCurrentFrame.fbCount;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800615
616 ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__,
617 mCurrentFrame.fbCount);
618}
Saurabh Shah85234ec2013-04-12 17:09:00 -0700619
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800620void MDPComp::updateLayerCache(hwc_context_t* ctx,
621 hwc_display_contents_1_t* list) {
622
623 int numAppLayers = ctx->listStats[mDpy].numAppLayers;
624 int numCacheableLayers = 0;
625
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800626 for(int i = 0; i < numAppLayers; i++) {
627 if (mCachedFrame.hnd[i] == list->hwLayers[i].handle) {
628 numCacheableLayers++;
629 mCurrentFrame.isFBComposed[i] = true;
630 } else {
Saurabh Shahaa236822013-04-24 18:07:26 -0700631 mCurrentFrame.isFBComposed[i] = false;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800632 mCachedFrame.hnd[i] = list->hwLayers[i].handle;
633 }
634 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700635
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800636 mCurrentFrame.fbCount = numCacheableLayers;
Saurabh Shahaa236822013-04-24 18:07:26 -0700637 mCurrentFrame.mdpCount = mCurrentFrame.layerCount -
638 mCurrentFrame.fbCount;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800639 ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__, numCacheableLayers);
640}
641
642int MDPComp::getAvailablePipes(hwc_context_t* ctx) {
643 int numDMAPipes = qdutils::MDPVersion::getInstance().getDMAPipes();
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800644 overlay::Overlay& ov = *ctx->mOverlay;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800645
646 int numAvailable = ov.availablePipes(mDpy);
647
648 //Reserve DMA for rotator
Saurabh Shah85234ec2013-04-12 17:09:00 -0700649 if(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE)
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800650 numAvailable -= numDMAPipes;
651
652 //Reserve pipe(s)for FB
653 if(mCurrentFrame.fbCount)
654 numAvailable -= pipesForFB();
655
656 return numAvailable;
657}
658
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800659void MDPComp::updateYUV(hwc_context_t* ctx, hwc_display_contents_1_t* list) {
660
661 int nYuvCount = ctx->listStats[mDpy].yuvCount;
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700662 if(!nYuvCount && mDpy) {
663 //Reset "No animation on external display" related parameters.
664 ctx->mPrevCropVideo.left = ctx->mPrevCropVideo.top =
665 ctx->mPrevCropVideo.right = ctx->mPrevCropVideo.bottom = 0;
666 ctx->mPrevDestVideo.left = ctx->mPrevDestVideo.top =
667 ctx->mPrevDestVideo.right = ctx->mPrevDestVideo.bottom = 0;
668 ctx->mPrevTransformVideo = 0;
669 return;
670 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800671 for(int index = 0;index < nYuvCount; index++){
672 int nYuvIndex = ctx->listStats[mDpy].yuvIndices[index];
673 hwc_layer_1_t* layer = &list->hwLayers[nYuvIndex];
674
675 if(!isYUVDoable(ctx, layer)) {
676 if(!mCurrentFrame.isFBComposed[nYuvIndex]) {
677 mCurrentFrame.isFBComposed[nYuvIndex] = true;
678 mCurrentFrame.fbCount++;
679 }
680 } else {
681 if(mCurrentFrame.isFBComposed[nYuvIndex]) {
682 mCurrentFrame.isFBComposed[nYuvIndex] = false;
683 mCurrentFrame.fbCount--;
684 }
685 }
686 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700687
688 mCurrentFrame.mdpCount = mCurrentFrame.layerCount -
689 mCurrentFrame.fbCount;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800690 ALOGD_IF(isDebug(),"%s: cached count: %d",__FUNCTION__,
691 mCurrentFrame.fbCount);
692}
693
Saurabh Shahaa236822013-04-24 18:07:26 -0700694bool MDPComp::programMDP(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800695 if(!allocLayerPipes(ctx, list)) {
696 ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__);
Saurabh Shahaa236822013-04-24 18:07:26 -0700697 return false;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800698 }
699
Saurabh Shahaa236822013-04-24 18:07:26 -0700700 bool fbBatch = false;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800701 for (int index = 0, mdpNextZOrder = 0; index < mCurrentFrame.layerCount;
Saurabh Shahaa236822013-04-24 18:07:26 -0700702 index++) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800703 if(!mCurrentFrame.isFBComposed[index]) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800704 int mdpIndex = mCurrentFrame.layerToMDP[index];
705 hwc_layer_1_t* layer = &list->hwLayers[index];
706
707 MdpPipeInfo* cur_pipe = mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
708 cur_pipe->zOrder = mdpNextZOrder++;
709
710 if(configure(ctx, layer, mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){
711 ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \
712 layer %d",__FUNCTION__, index);
Saurabh Shahaa236822013-04-24 18:07:26 -0700713 return false;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800714 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700715 } else if(fbBatch == false) {
716 mdpNextZOrder++;
717 fbBatch = true;
718 }
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800719 }
720
Saurabh Shahaa236822013-04-24 18:07:26 -0700721 return true;
722}
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800723
Saurabh Shahaa236822013-04-24 18:07:26 -0700724bool MDPComp::programYUV(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
725 if(!allocLayerPipes(ctx, list)) {
726 ALOGD_IF(isDebug(), "%s: Unable to allocate MDP pipes", __FUNCTION__);
727 return false;
728 }
729 //If we are in this block, it means we have yuv + rgb layers both
730 int mdpIdx = 0;
731 for (int index = 0; index < mCurrentFrame.layerCount; index++) {
732 if(!mCurrentFrame.isFBComposed[index]) {
733 hwc_layer_1_t* layer = &list->hwLayers[index];
734 int mdpIndex = mCurrentFrame.layerToMDP[index];
735 MdpPipeInfo* cur_pipe =
736 mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
737 cur_pipe->zOrder = mdpIdx++;
738
739 if(configure(ctx, layer,
740 mCurrentFrame.mdpToLayer[mdpIndex]) != 0 ){
741 ALOGD_IF(isDebug(), "%s: Failed to configure overlay for \
742 layer %d",__FUNCTION__, index);
743 return false;
744 }
745 }
746 }
747 return true;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800748}
749
750int MDPComp::prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800751
Saurabh Shahaa236822013-04-24 18:07:26 -0700752 const int numLayers = ctx->listStats[mDpy].numAppLayers;
Ramkumar Radhakrishnanc5893f12013-06-06 19:43:53 -0700753
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530754 { //LOCK SCOPE BEGIN
755 Locker::Autolock _l(mMdpCompLock);
Prabhanjan Kandula088bd892013-07-02 23:47:13 +0530756
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530757 //reset old data
Saurabh Shahaa236822013-04-24 18:07:26 -0700758 mCurrentFrame.reset(numLayers);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800759
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530760 //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU
761 //do not cache the information for next draw cycle.
762 if(numLayers > MAX_NUM_APP_LAYERS) {
763 mCachedFrame.updateCounts(mCurrentFrame);
764 ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ",
765 __FUNCTION__);
766 return 0;
767 }
768
769 //Hard conditions, if not met, cannot do MDP comp
770 if(!isFrameDoable(ctx)) {
771 ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame",
772 __FUNCTION__);
Saurabh Shah2f3895f2013-05-02 10:13:31 -0700773 mCurrentFrame.reset(numLayers);
774 mCachedFrame.cacheAll(list);
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530775 mCachedFrame.updateCounts(mCurrentFrame);
776 return 0;
777 }
778
779 //Check whether layers marked for MDP Composition is actually doable.
780 if(isFullFrameDoable(ctx, list)){
781 mCurrentFrame.map();
782 //Acquire and Program MDP pipes
783 if(!programMDP(ctx, list)) {
784 mCurrentFrame.reset(numLayers);
785 mCachedFrame.cacheAll(list);
786 } else { //Success
787 //Any change in composition types needs an FB refresh
788 mCurrentFrame.needsRedraw = false;
789 if(mCurrentFrame.fbCount &&
790 ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) ||
791 (mCurrentFrame.fbCount != mCachedFrame.cacheCount) ||
792 (mCurrentFrame.fbZ != mCachedFrame.fbZ) ||
793 (!mCurrentFrame.mdpCount) ||
794 (list->flags & HWC_GEOMETRY_CHANGED) ||
795 isSkipPresent(ctx, mDpy) ||
796 (mDpy > HWC_DISPLAY_PRIMARY))) {
797 mCurrentFrame.needsRedraw = true;
798 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700799 }
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530800 } else if(isOnlyVideoDoable(ctx, list)) {
801 //All layers marked for MDP comp cannot be bypassed.
802 //Try to compose atleast YUV layers through MDP comp and let
803 //all the RGB layers compose in FB
804 //Destination over
805 mCurrentFrame.fbZ = -1;
806 if(mCurrentFrame.fbCount)
807 mCurrentFrame.fbZ = mCurrentFrame.mdpCount;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800808
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530809 mCurrentFrame.map();
810 if(!programYUV(ctx, list)) {
811 mCurrentFrame.reset(numLayers);
812 mCachedFrame.cacheAll(list);
813 }
814 } else {
Saurabh Shahaa236822013-04-24 18:07:26 -0700815 mCurrentFrame.reset(numLayers);
816 mCachedFrame.cacheAll(list);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800817 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800818
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530819 //UpdateLayerFlags
820 setMDPCompLayerFlags(ctx, list);
821 mCachedFrame.updateCounts(mCurrentFrame);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800822
Prabhanjan Kandula25469a52013-07-12 16:19:31 +0530823 } //LOCK SCOPE END. dump also need this lock.
824 // unlock it before calling dump function to avoid deadlock
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800825 if(isDebug()) {
Saurabh Shahaa236822013-04-24 18:07:26 -0700826 ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED));
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800827 android::String8 sDump("");
828 dump(sDump);
829 ALOGE("%s",sDump.string());
830 }
831
832 return mCurrentFrame.fbZ;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800833}
834
835//=============MDPCompLowRes===================================================
836
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700837/*
838 * Configures pipe(s) for MDP composition
839 */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800840int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800841 PipeLayerPair& PipeLayerPair) {
Saurabh Shahacf10202013-02-26 10:15:15 -0800842 MdpPipeInfoLowRes& mdp_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800843 *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo));
Saurabh Shahacf10202013-02-26 10:15:15 -0800844 eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION;
845 eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder);
846 eIsFg isFg = IS_FG_OFF;
847 eDest dest = mdp_info.index;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700848
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800849 ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d",
850 __FUNCTION__, layer, zOrder, dest);
851
852 return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest,
853 &PipeLayerPair.rot);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700854}
855
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800856int MDPCompLowRes::pipesNeeded(hwc_context_t *ctx,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800857 hwc_display_contents_1_t* list) {
858 return mCurrentFrame.mdpCount;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700859}
860
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800861bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx,
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700862 hwc_display_contents_1_t* list) {
863 for(int index = 0; index < mCurrentFrame.layerCount; index++) {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700864
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800865 if(mCurrentFrame.isFBComposed[index]) continue;
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700866
Jeykumar Sankarancf537002013-01-21 21:19:15 -0800867 hwc_layer_1_t* layer = &list->hwLayers[index];
868 private_handle_t *hnd = (private_handle_t *)layer->handle;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800869 int mdpIndex = mCurrentFrame.layerToMDP[index];
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800870 PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex];
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800871 info.pipeInfo = new MdpPipeInfoLowRes;
Saurabh Shahacf10202013-02-26 10:15:15 -0800872 info.rot = NULL;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800873 MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo;
Jeykumar Sankarana37fdbf2013-03-06 18:59:28 -0800874 ePipeType type = MDPCOMP_OV_ANY;
875
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700876 if(isYuvBuffer(hnd)) {
877 type = MDPCOMP_OV_VG;
Saurabh Shah8a117932013-05-23 12:48:13 -0700878 } else if(!qhwc::needsScaling(ctx, layer, mDpy)
Saurabh Shah85234ec2013-04-12 17:09:00 -0700879 && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
880 && ctx->mMDP.version >= qdutils::MDSS_V5) {
Jeykumar Sankarana37fdbf2013-03-06 18:59:28 -0800881 type = MDPCOMP_OV_DMA;
882 }
883
884 pipe_info.index = getMdpPipe(ctx, type);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800885 if(pipe_info.index == ovutils::OV_INVALID) {
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700886 ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d",
887 __FUNCTION__, (int) type);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500888 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700889 }
890 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700891 return true;
892}
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700893
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800894bool MDPCompLowRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700895
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800896 if(!isEnabled()) {
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500897 ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__);
898 return true;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800899 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700900
901 if(!ctx || !list) {
902 ALOGE("%s: invalid contxt or list",__FUNCTION__);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500903 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700904 }
905
Prabhanjan Kandula08222fc2013-07-10 17:20:59 +0530906 if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) {
907 ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__);
908 return true;
909 }
910
Prabhanjan Kandula088bd892013-07-02 23:47:13 +0530911 Locker::Autolock _l(mMdpCompLock);
912
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500913 /* reset Invalidator */
Saurabh Shah2d998a92013-05-14 17:55:58 -0700914 if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount)
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500915 idleInvalidator->markForSleep();
916
917 overlay::Overlay& ov = *ctx->mOverlay;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800918 LayerProp *layerProp = ctx->layerProp[mDpy];
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700919
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800920 int numHwLayers = ctx->listStats[mDpy].numAppLayers;
921 for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ )
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700922 {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800923 if(mCurrentFrame.isFBComposed[i]) continue;
924
Naseer Ahmed5b6708a2012-08-02 13:46:08 -0700925 hwc_layer_1_t *layer = &list->hwLayers[i];
Saurabh Shahacf10202013-02-26 10:15:15 -0800926 private_handle_t *hnd = (private_handle_t *)layer->handle;
927 if(!hnd) {
928 ALOGE("%s handle null", __FUNCTION__);
929 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700930 }
931
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800932 int mdpIndex = mCurrentFrame.layerToMDP[i];
933
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800934 MdpPipeInfoLowRes& pipe_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800935 *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800936 ovutils::eDest dest = pipe_info.index;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800937 if(dest == ovutils::OV_INVALID) {
938 ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500939 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700940 }
941
Saurabh Shahacf10202013-02-26 10:15:15 -0800942 if(!(layerProp[i].mFlags & HWC_MDPCOMP)) {
943 continue;
944 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700945
Saurabh Shahacf10202013-02-26 10:15:15 -0800946 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800947 using pipe: %d", __FUNCTION__, layer,
948 hnd, dest );
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700949
Saurabh Shahacf10202013-02-26 10:15:15 -0800950 int fd = hnd->fd;
951 uint32_t offset = hnd->offset;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800952 Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
Saurabh Shahacf10202013-02-26 10:15:15 -0800953 if(rot) {
954 if(!rot->queueBuffer(fd, offset))
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500955 return false;
Saurabh Shahacf10202013-02-26 10:15:15 -0800956 fd = rot->getDstMemId();
957 offset = rot->getDstOffset();
958 }
959
960 if (!ov.queueBuffer(fd, offset, dest)) {
Prabhanjan Kandula08222fc2013-07-10 17:20:59 +0530961 ALOGE("%s: queueBuffer failed for display:%d ", __FUNCTION__, mDpy);
Saurabh Shahacf10202013-02-26 10:15:15 -0800962 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700963 }
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500964
965 layerProp[i].mFlags &= ~HWC_MDPCOMP;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700966 }
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500967 return true;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700968}
969
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800970//=============MDPCompHighRes===================================================
971
972int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700973 hwc_display_contents_1_t* list) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800974 int pipesNeeded = 0;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700975 const int xres = ctx->dpyAttr[mDpy].xres;
976 //Default even split for all displays with high res
977 int lSplit = xres / 2;
978 if(mDpy == HWC_DISPLAY_PRIMARY &&
979 qdutils::MDPVersion::getInstance().getLeftSplit()) {
980 //Override if split published by driver for primary
981 lSplit = qdutils::MDPVersion::getInstance().getLeftSplit();
982 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800983
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800984 for(int i = 0; i < mCurrentFrame.layerCount; ++i) {
985 if(!mCurrentFrame.isFBComposed[i]) {
986 hwc_layer_1_t* layer = &list->hwLayers[i];
987 hwc_rect_t dst = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700988 if(dst.left > lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800989 pipesNeeded++;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700990 } else if(dst.right <= lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800991 pipesNeeded++;
992 } else {
993 pipesNeeded += 2;
994 }
995 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800996 }
997 return pipesNeeded;
998}
999
1000bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer,
Saurabh Shah67a38c32013-06-10 16:23:15 -07001001 MdpPipeInfoHighRes& pipe_info,
1002 ePipeType type) {
1003 const int xres = ctx->dpyAttr[mDpy].xres;
1004 //Default even split for all displays with high res
1005 int lSplit = xres / 2;
1006 if(mDpy == HWC_DISPLAY_PRIMARY &&
1007 qdutils::MDPVersion::getInstance().getLeftSplit()) {
1008 //Override if split published by driver for primary
1009 lSplit = qdutils::MDPVersion::getInstance().getLeftSplit();
1010 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001011
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001012 hwc_rect_t dst = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -07001013 if(dst.left > lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001014 pipe_info.lIndex = ovutils::OV_INVALID;
1015 pipe_info.rIndex = getMdpPipe(ctx, type);
1016 if(pipe_info.rIndex == ovutils::OV_INVALID)
1017 return false;
Saurabh Shah67a38c32013-06-10 16:23:15 -07001018 } else if (dst.right <= lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001019 pipe_info.rIndex = ovutils::OV_INVALID;
1020 pipe_info.lIndex = getMdpPipe(ctx, type);
1021 if(pipe_info.lIndex == ovutils::OV_INVALID)
1022 return false;
1023 } else {
1024 pipe_info.rIndex = getMdpPipe(ctx, type);
1025 pipe_info.lIndex = getMdpPipe(ctx, type);
1026 if(pipe_info.rIndex == ovutils::OV_INVALID ||
1027 pipe_info.lIndex == ovutils::OV_INVALID)
1028 return false;
1029 }
1030 return true;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001031}
1032
1033bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx,
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001034 hwc_display_contents_1_t* list) {
1035 for(int index = 0 ; index < mCurrentFrame.layerCount; index++) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001036
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001037 if(mCurrentFrame.isFBComposed[index]) continue;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001038
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001039 hwc_layer_1_t* layer = &list->hwLayers[index];
1040 private_handle_t *hnd = (private_handle_t *)layer->handle;
Saurabh Shah0d65dbe2013-06-06 18:33:16 -07001041 int mdpIndex = mCurrentFrame.layerToMDP[index];
1042 PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex];
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001043 info.pipeInfo = new MdpPipeInfoHighRes;
Saurabh Shah9e3adb22013-03-26 11:16:27 -07001044 info.rot = NULL;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001045 MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001046 ePipeType type = MDPCOMP_OV_ANY;
1047
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001048 if(isYuvBuffer(hnd)) {
1049 type = MDPCOMP_OV_VG;
Saurabh Shah8a117932013-05-23 12:48:13 -07001050 } else if(!qhwc::needsScaling(ctx, layer, mDpy)
Saurabh Shah85234ec2013-04-12 17:09:00 -07001051 && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001052 && ctx->mMDP.version >= qdutils::MDSS_V5) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001053 type = MDPCOMP_OV_DMA;
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001054 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001055
1056 if(!acquireMDPPipes(ctx, layer, pipe_info, type)) {
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001057 ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d",
1058 __FUNCTION__, (int) type);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001059 return false;
1060 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001061 }
1062 return true;
1063}
1064/*
1065 * Configures pipe(s) for MDP composition
1066 */
1067int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Saurabh Shah67a38c32013-06-10 16:23:15 -07001068 PipeLayerPair& PipeLayerPair) {
Saurabh Shahacf10202013-02-26 10:15:15 -08001069 MdpPipeInfoHighRes& mdp_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001070 *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo));
Saurabh Shahacf10202013-02-26 10:15:15 -08001071 eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder);
1072 eIsFg isFg = IS_FG_OFF;
1073 eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION;
1074 eDest lDest = mdp_info.lIndex;
1075 eDest rDest = mdp_info.rIndex;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001076
1077 ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d"
1078 "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest);
1079
1080 return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest,
1081 rDest, &PipeLayerPair.rot);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001082}
1083
1084bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
1085
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001086 if(!isEnabled()) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001087 ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__);
1088 return true;
1089 }
1090
1091 if(!ctx || !list) {
1092 ALOGE("%s: invalid contxt or list",__FUNCTION__);
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001093 return false;
1094 }
1095
Prabhanjan Kandula08222fc2013-07-10 17:20:59 +05301096 if(ctx->listStats[mDpy].numAppLayers > MAX_NUM_APP_LAYERS) {
1097 ALOGD_IF(isDebug(),"%s: Exceeding max layer count", __FUNCTION__);
1098 return true;
1099 }
1100
Prabhanjan Kandula088bd892013-07-02 23:47:13 +05301101 Locker::Autolock _l(mMdpCompLock);
1102
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001103 /* reset Invalidator */
Saurabh Shah2d998a92013-05-14 17:55:58 -07001104 if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount)
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001105 idleInvalidator->markForSleep();
1106
Naseer Ahmed54821fe2012-11-28 18:44:38 -05001107 overlay::Overlay& ov = *ctx->mOverlay;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001108 LayerProp *layerProp = ctx->layerProp[mDpy];
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001109
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001110 int numHwLayers = ctx->listStats[mDpy].numAppLayers;
1111 for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ )
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001112 {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001113 if(mCurrentFrame.isFBComposed[i]) continue;
1114
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001115 hwc_layer_1_t *layer = &list->hwLayers[i];
Saurabh Shahacf10202013-02-26 10:15:15 -08001116 private_handle_t *hnd = (private_handle_t *)layer->handle;
1117 if(!hnd) {
1118 ALOGE("%s handle null", __FUNCTION__);
1119 return false;
1120 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001121
1122 if(!(layerProp[i].mFlags & HWC_MDPCOMP)) {
1123 continue;
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001124 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001125
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001126 int mdpIndex = mCurrentFrame.layerToMDP[i];
1127
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001128 MdpPipeInfoHighRes& pipe_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001129 *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
1130 Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
Saurabh Shahacf10202013-02-26 10:15:15 -08001131
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001132 ovutils::eDest indexL = pipe_info.lIndex;
1133 ovutils::eDest indexR = pipe_info.rIndex;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001134
Saurabh Shahacf10202013-02-26 10:15:15 -08001135 int fd = hnd->fd;
1136 int offset = hnd->offset;
1137
1138 if(rot) {
1139 rot->queueBuffer(fd, offset);
1140 fd = rot->getDstMemId();
1141 offset = rot->getDstOffset();
1142 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001143
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001144 //************* play left mixer **********
1145 if(indexL != ovutils::OV_INVALID) {
1146 ovutils::eDest destL = (ovutils::eDest)indexL;
Saurabh Shahacf10202013-02-26 10:15:15 -08001147 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001148 using pipe: %d", __FUNCTION__, layer, hnd, indexL );
Saurabh Shahacf10202013-02-26 10:15:15 -08001149 if (!ov.queueBuffer(fd, offset, destL)) {
1150 ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__);
1151 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001152 }
1153 }
1154
1155 //************* play right mixer **********
1156 if(indexR != ovutils::OV_INVALID) {
1157 ovutils::eDest destR = (ovutils::eDest)indexR;
Saurabh Shahacf10202013-02-26 10:15:15 -08001158 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001159 using pipe: %d", __FUNCTION__, layer, hnd, indexR );
Saurabh Shahacf10202013-02-26 10:15:15 -08001160 if (!ov.queueBuffer(fd, offset, destR)) {
1161 ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__);
1162 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001163 }
1164 }
Saurabh Shahacf10202013-02-26 10:15:15 -08001165
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001166 layerProp[i].mFlags &= ~HWC_MDPCOMP;
1167 }
Saurabh Shahacf10202013-02-26 10:15:15 -08001168
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001169 return true;
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001170}
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001171}; //namespace
1172