blob: f13a73ae8d53947fb562bf29df2a9d9dcb4c85f3 [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
754 //number of app layers exceeds MAX_NUM_APP_LAYERS fall back to GPU
755 //do not cache the information for next draw cycle.
756 if(numLayers > MAX_NUM_APP_LAYERS) {
757 ALOGD_IF(isDebug(), "%s: Number of App layers exceeded the limit ",
758 __FUNCTION__);
759 return 0;
760 }
Prabhanjan Kandula088bd892013-07-02 23:47:13 +0530761
762 Locker::Autolock _l(mMdpCompLock);
763
Ramkumar Radhakrishnanc5893f12013-06-06 19:43:53 -0700764 //reset old data
Saurabh Shahaa236822013-04-24 18:07:26 -0700765 mCurrentFrame.reset(numLayers);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800766
Saurabh Shahaa236822013-04-24 18:07:26 -0700767 //Hard conditions, if not met, cannot do MDP comp
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800768 if(!isFrameDoable(ctx)) {
769 ALOGD_IF( isDebug(),"%s: MDP Comp not possible for this frame",
770 __FUNCTION__);
Saurabh Shahaa236822013-04-24 18:07:26 -0700771 mCurrentFrame.reset(numLayers);
772 mCachedFrame.cacheAll(list);
773 mCachedFrame.updateCounts(mCurrentFrame);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800774 return 0;
775 }
776
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800777 //Check whether layers marked for MDP Composition is actually doable.
Saurabh Shahaa236822013-04-24 18:07:26 -0700778 if(isFullFrameDoable(ctx, list)){
Saurabh Shah2f3895f2013-05-02 10:13:31 -0700779 mCurrentFrame.map();
780 //Acquire and Program MDP pipes
781 if(!programMDP(ctx, list)) {
782 mCurrentFrame.reset(numLayers);
783 mCachedFrame.cacheAll(list);
784 } else { //Success
785 //Any change in composition types needs an FB refresh
786 mCurrentFrame.needsRedraw = false;
787 if(mCurrentFrame.fbCount &&
788 ((mCurrentFrame.mdpCount != mCachedFrame.mdpCount) ||
789 (mCurrentFrame.fbCount != mCachedFrame.cacheCount) ||
790 (mCurrentFrame.fbZ != mCachedFrame.fbZ) ||
791 (!mCurrentFrame.mdpCount) ||
792 (list->flags & HWC_GEOMETRY_CHANGED) ||
793 isSkipPresent(ctx, mDpy) ||
794 (mDpy > HWC_DISPLAY_PRIMARY))) {
795 mCurrentFrame.needsRedraw = true;
Saurabh Shahaa236822013-04-24 18:07:26 -0700796 }
797 }
798 } else if(isOnlyVideoDoable(ctx, list)) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800799 //All layers marked for MDP comp cannot be bypassed.
800 //Try to compose atleast YUV layers through MDP comp and let
801 //all the RGB layers compose in FB
Saurabh Shahaa236822013-04-24 18:07:26 -0700802 //Destination over
803 mCurrentFrame.fbZ = -1;
804 if(mCurrentFrame.fbCount)
Saurabh Shahe8e76272013-06-12 16:08:06 -0700805 mCurrentFrame.fbZ = mCurrentFrame.mdpCount;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800806
Saurabh Shahaa236822013-04-24 18:07:26 -0700807 mCurrentFrame.map();
808 if(!programYUV(ctx, list)) {
809 mCurrentFrame.reset(numLayers);
810 mCachedFrame.cacheAll(list);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800811 }
Saurabh Shahaa236822013-04-24 18:07:26 -0700812 } else {
813 mCurrentFrame.reset(numLayers);
814 mCachedFrame.cacheAll(list);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800815 }
816
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800817 //UpdateLayerFlags
818 setMDPCompLayerFlags(ctx, list);
Saurabh Shahaa236822013-04-24 18:07:26 -0700819 mCachedFrame.updateCounts(mCurrentFrame);
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800820
821 if(isDebug()) {
Saurabh Shahaa236822013-04-24 18:07:26 -0700822 ALOGD("GEOMETRY change: %d", (list->flags & HWC_GEOMETRY_CHANGED));
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800823 android::String8 sDump("");
824 dump(sDump);
825 ALOGE("%s",sDump.string());
826 }
827
828 return mCurrentFrame.fbZ;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800829}
830
831//=============MDPCompLowRes===================================================
832
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700833/*
834 * Configures pipe(s) for MDP composition
835 */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800836int MDPCompLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800837 PipeLayerPair& PipeLayerPair) {
Saurabh Shahacf10202013-02-26 10:15:15 -0800838 MdpPipeInfoLowRes& mdp_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800839 *(static_cast<MdpPipeInfoLowRes*>(PipeLayerPair.pipeInfo));
Saurabh Shahacf10202013-02-26 10:15:15 -0800840 eMdpFlags mdpFlags = OV_MDP_BACKEND_COMPOSITION;
841 eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder);
842 eIsFg isFg = IS_FG_OFF;
843 eDest dest = mdp_info.index;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700844
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800845 ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipe: %d",
846 __FUNCTION__, layer, zOrder, dest);
847
848 return configureLowRes(ctx, layer, mDpy, mdpFlags, zOrder, isFg, dest,
849 &PipeLayerPair.rot);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700850}
851
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800852int MDPCompLowRes::pipesNeeded(hwc_context_t *ctx,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800853 hwc_display_contents_1_t* list) {
854 return mCurrentFrame.mdpCount;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700855}
856
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800857bool MDPCompLowRes::allocLayerPipes(hwc_context_t *ctx,
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700858 hwc_display_contents_1_t* list) {
859 for(int index = 0; index < mCurrentFrame.layerCount; index++) {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700860
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800861 if(mCurrentFrame.isFBComposed[index]) continue;
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700862
Jeykumar Sankarancf537002013-01-21 21:19:15 -0800863 hwc_layer_1_t* layer = &list->hwLayers[index];
864 private_handle_t *hnd = (private_handle_t *)layer->handle;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800865 int mdpIndex = mCurrentFrame.layerToMDP[index];
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800866 PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex];
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800867 info.pipeInfo = new MdpPipeInfoLowRes;
Saurabh Shahacf10202013-02-26 10:15:15 -0800868 info.rot = NULL;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800869 MdpPipeInfoLowRes& pipe_info = *(MdpPipeInfoLowRes*)info.pipeInfo;
Jeykumar Sankarana37fdbf2013-03-06 18:59:28 -0800870 ePipeType type = MDPCOMP_OV_ANY;
871
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700872 if(isYuvBuffer(hnd)) {
873 type = MDPCOMP_OV_VG;
Saurabh Shah8a117932013-05-23 12:48:13 -0700874 } else if(!qhwc::needsScaling(ctx, layer, mDpy)
Saurabh Shah85234ec2013-04-12 17:09:00 -0700875 && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
876 && ctx->mMDP.version >= qdutils::MDSS_V5) {
Jeykumar Sankarana37fdbf2013-03-06 18:59:28 -0800877 type = MDPCOMP_OV_DMA;
878 }
879
880 pipe_info.index = getMdpPipe(ctx, type);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800881 if(pipe_info.index == ovutils::OV_INVALID) {
Saurabh Shahe51f8ca2013-05-06 17:26:16 -0700882 ALOGD_IF(isDebug(), "%s: Unable to get pipe type = %d",
883 __FUNCTION__, (int) type);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500884 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700885 }
886 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700887 return true;
888}
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700889
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800890bool MDPCompLowRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700891
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800892 if(!isEnabled()) {
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500893 ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__);
894 return true;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800895 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700896
897 if(!ctx || !list) {
898 ALOGE("%s: invalid contxt or list",__FUNCTION__);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500899 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700900 }
901
Prabhanjan Kandula088bd892013-07-02 23:47:13 +0530902 Locker::Autolock _l(mMdpCompLock);
903
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500904 /* reset Invalidator */
Saurabh Shah2d998a92013-05-14 17:55:58 -0700905 if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount)
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500906 idleInvalidator->markForSleep();
907
908 overlay::Overlay& ov = *ctx->mOverlay;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800909 LayerProp *layerProp = ctx->layerProp[mDpy];
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700910
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800911 int numHwLayers = ctx->listStats[mDpy].numAppLayers;
912 for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ )
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700913 {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800914 if(mCurrentFrame.isFBComposed[i]) continue;
915
Naseer Ahmed5b6708a2012-08-02 13:46:08 -0700916 hwc_layer_1_t *layer = &list->hwLayers[i];
Saurabh Shahacf10202013-02-26 10:15:15 -0800917 private_handle_t *hnd = (private_handle_t *)layer->handle;
918 if(!hnd) {
919 ALOGE("%s handle null", __FUNCTION__);
920 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700921 }
922
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800923 int mdpIndex = mCurrentFrame.layerToMDP[i];
924
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800925 MdpPipeInfoLowRes& pipe_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800926 *(MdpPipeInfoLowRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800927 ovutils::eDest dest = pipe_info.index;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800928 if(dest == ovutils::OV_INVALID) {
929 ALOGE("%s: Invalid pipe index (%d)", __FUNCTION__, dest);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500930 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700931 }
932
Saurabh Shahacf10202013-02-26 10:15:15 -0800933 if(!(layerProp[i].mFlags & HWC_MDPCOMP)) {
934 continue;
935 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700936
Saurabh Shahacf10202013-02-26 10:15:15 -0800937 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800938 using pipe: %d", __FUNCTION__, layer,
939 hnd, dest );
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700940
Saurabh Shahacf10202013-02-26 10:15:15 -0800941 int fd = hnd->fd;
942 uint32_t offset = hnd->offset;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800943 Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
Saurabh Shahacf10202013-02-26 10:15:15 -0800944 if(rot) {
945 if(!rot->queueBuffer(fd, offset))
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500946 return false;
Saurabh Shahacf10202013-02-26 10:15:15 -0800947 fd = rot->getDstMemId();
948 offset = rot->getDstOffset();
949 }
950
951 if (!ov.queueBuffer(fd, offset, dest)) {
952 ALOGE("%s: queueBuffer failed for external", __FUNCTION__);
953 return false;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700954 }
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500955
956 layerProp[i].mFlags &= ~HWC_MDPCOMP;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700957 }
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500958 return true;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700959}
960
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800961//=============MDPCompHighRes===================================================
962
963int MDPCompHighRes::pipesNeeded(hwc_context_t *ctx,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700964 hwc_display_contents_1_t* list) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800965 int pipesNeeded = 0;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700966 const int xres = ctx->dpyAttr[mDpy].xres;
967 //Default even split for all displays with high res
968 int lSplit = xres / 2;
969 if(mDpy == HWC_DISPLAY_PRIMARY &&
970 qdutils::MDPVersion::getInstance().getLeftSplit()) {
971 //Override if split published by driver for primary
972 lSplit = qdutils::MDPVersion::getInstance().getLeftSplit();
973 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800974
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800975 for(int i = 0; i < mCurrentFrame.layerCount; ++i) {
976 if(!mCurrentFrame.isFBComposed[i]) {
977 hwc_layer_1_t* layer = &list->hwLayers[i];
978 hwc_rect_t dst = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700979 if(dst.left > lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800980 pipesNeeded++;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700981 } else if(dst.right <= lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800982 pipesNeeded++;
983 } else {
984 pipesNeeded += 2;
985 }
986 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800987 }
988 return pipesNeeded;
989}
990
991bool MDPCompHighRes::acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700992 MdpPipeInfoHighRes& pipe_info,
993 ePipeType type) {
994 const int xres = ctx->dpyAttr[mDpy].xres;
995 //Default even split for all displays with high res
996 int lSplit = xres / 2;
997 if(mDpy == HWC_DISPLAY_PRIMARY &&
998 qdutils::MDPVersion::getInstance().getLeftSplit()) {
999 //Override if split published by driver for primary
1000 lSplit = qdutils::MDPVersion::getInstance().getLeftSplit();
1001 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001002
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001003 hwc_rect_t dst = layer->displayFrame;
Saurabh Shah67a38c32013-06-10 16:23:15 -07001004 if(dst.left > lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001005 pipe_info.lIndex = ovutils::OV_INVALID;
1006 pipe_info.rIndex = getMdpPipe(ctx, type);
1007 if(pipe_info.rIndex == ovutils::OV_INVALID)
1008 return false;
Saurabh Shah67a38c32013-06-10 16:23:15 -07001009 } else if (dst.right <= lSplit) {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001010 pipe_info.rIndex = ovutils::OV_INVALID;
1011 pipe_info.lIndex = getMdpPipe(ctx, type);
1012 if(pipe_info.lIndex == ovutils::OV_INVALID)
1013 return false;
1014 } else {
1015 pipe_info.rIndex = getMdpPipe(ctx, type);
1016 pipe_info.lIndex = getMdpPipe(ctx, type);
1017 if(pipe_info.rIndex == ovutils::OV_INVALID ||
1018 pipe_info.lIndex == ovutils::OV_INVALID)
1019 return false;
1020 }
1021 return true;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001022}
1023
1024bool MDPCompHighRes::allocLayerPipes(hwc_context_t *ctx,
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001025 hwc_display_contents_1_t* list) {
1026 for(int index = 0 ; index < mCurrentFrame.layerCount; index++) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001027
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001028 if(mCurrentFrame.isFBComposed[index]) continue;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001029
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001030 hwc_layer_1_t* layer = &list->hwLayers[index];
1031 private_handle_t *hnd = (private_handle_t *)layer->handle;
Saurabh Shah0d65dbe2013-06-06 18:33:16 -07001032 int mdpIndex = mCurrentFrame.layerToMDP[index];
1033 PipeLayerPair& info = mCurrentFrame.mdpToLayer[mdpIndex];
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001034 info.pipeInfo = new MdpPipeInfoHighRes;
Saurabh Shah9e3adb22013-03-26 11:16:27 -07001035 info.rot = NULL;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001036 MdpPipeInfoHighRes& pipe_info = *(MdpPipeInfoHighRes*)info.pipeInfo;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001037 ePipeType type = MDPCOMP_OV_ANY;
1038
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001039 if(isYuvBuffer(hnd)) {
1040 type = MDPCOMP_OV_VG;
Saurabh Shah8a117932013-05-23 12:48:13 -07001041 } else if(!qhwc::needsScaling(ctx, layer, mDpy)
Saurabh Shah85234ec2013-04-12 17:09:00 -07001042 && Overlay::getDMAMode() != Overlay::DMA_BLOCK_MODE
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001043 && ctx->mMDP.version >= qdutils::MDSS_V5) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001044 type = MDPCOMP_OV_DMA;
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001045 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001046
1047 if(!acquireMDPPipes(ctx, layer, pipe_info, type)) {
Saurabh Shahe51f8ca2013-05-06 17:26:16 -07001048 ALOGD_IF(isDebug(), "%s: Unable to get pipe for type = %d",
1049 __FUNCTION__, (int) type);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001050 return false;
1051 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001052 }
1053 return true;
1054}
1055/*
1056 * Configures pipe(s) for MDP composition
1057 */
1058int MDPCompHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Saurabh Shah67a38c32013-06-10 16:23:15 -07001059 PipeLayerPair& PipeLayerPair) {
Saurabh Shahacf10202013-02-26 10:15:15 -08001060 MdpPipeInfoHighRes& mdp_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001061 *(static_cast<MdpPipeInfoHighRes*>(PipeLayerPair.pipeInfo));
Saurabh Shahacf10202013-02-26 10:15:15 -08001062 eZorder zOrder = static_cast<eZorder>(mdp_info.zOrder);
1063 eIsFg isFg = IS_FG_OFF;
1064 eMdpFlags mdpFlagsL = OV_MDP_BACKEND_COMPOSITION;
1065 eDest lDest = mdp_info.lIndex;
1066 eDest rDest = mdp_info.rIndex;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001067
1068 ALOGD_IF(isDebug(),"%s: configuring: layer: %p z_order: %d dest_pipeL: %d"
1069 "dest_pipeR: %d",__FUNCTION__, layer, zOrder, lDest, rDest);
1070
1071 return configureHighRes(ctx, layer, mDpy, mdpFlagsL, zOrder, isFg, lDest,
1072 rDest, &PipeLayerPair.rot);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001073}
1074
1075bool MDPCompHighRes::draw(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
1076
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001077 if(!isEnabled()) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001078 ALOGD_IF(isDebug(),"%s: MDP Comp not configured", __FUNCTION__);
1079 return true;
1080 }
1081
1082 if(!ctx || !list) {
1083 ALOGE("%s: invalid contxt or list",__FUNCTION__);
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001084 return false;
1085 }
1086
Prabhanjan Kandula088bd892013-07-02 23:47:13 +05301087 Locker::Autolock _l(mMdpCompLock);
1088
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001089 /* reset Invalidator */
Saurabh Shah2d998a92013-05-14 17:55:58 -07001090 if(idleInvalidator && !sIdleFallBack && mCurrentFrame.mdpCount)
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001091 idleInvalidator->markForSleep();
1092
Naseer Ahmed54821fe2012-11-28 18:44:38 -05001093 overlay::Overlay& ov = *ctx->mOverlay;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001094 LayerProp *layerProp = ctx->layerProp[mDpy];
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001095
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001096 int numHwLayers = ctx->listStats[mDpy].numAppLayers;
1097 for(int i = 0; i < numHwLayers && mCurrentFrame.mdpCount; i++ )
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001098 {
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001099 if(mCurrentFrame.isFBComposed[i]) continue;
1100
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001101 hwc_layer_1_t *layer = &list->hwLayers[i];
Saurabh Shahacf10202013-02-26 10:15:15 -08001102 private_handle_t *hnd = (private_handle_t *)layer->handle;
1103 if(!hnd) {
1104 ALOGE("%s handle null", __FUNCTION__);
1105 return false;
1106 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001107
1108 if(!(layerProp[i].mFlags & HWC_MDPCOMP)) {
1109 continue;
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001110 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001111
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001112 int mdpIndex = mCurrentFrame.layerToMDP[i];
1113
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001114 MdpPipeInfoHighRes& pipe_info =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001115 *(MdpPipeInfoHighRes*)mCurrentFrame.mdpToLayer[mdpIndex].pipeInfo;
1116 Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
Saurabh Shahacf10202013-02-26 10:15:15 -08001117
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001118 ovutils::eDest indexL = pipe_info.lIndex;
1119 ovutils::eDest indexR = pipe_info.rIndex;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001120
Saurabh Shahacf10202013-02-26 10:15:15 -08001121 int fd = hnd->fd;
1122 int offset = hnd->offset;
1123
1124 if(rot) {
1125 rot->queueBuffer(fd, offset);
1126 fd = rot->getDstMemId();
1127 offset = rot->getDstOffset();
1128 }
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001129
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001130 //************* play left mixer **********
1131 if(indexL != ovutils::OV_INVALID) {
1132 ovutils::eDest destL = (ovutils::eDest)indexL;
Saurabh Shahacf10202013-02-26 10:15:15 -08001133 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001134 using pipe: %d", __FUNCTION__, layer, hnd, indexL );
Saurabh Shahacf10202013-02-26 10:15:15 -08001135 if (!ov.queueBuffer(fd, offset, destL)) {
1136 ALOGE("%s: queueBuffer failed for left mixer", __FUNCTION__);
1137 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001138 }
1139 }
1140
1141 //************* play right mixer **********
1142 if(indexR != ovutils::OV_INVALID) {
1143 ovutils::eDest destR = (ovutils::eDest)indexR;
Saurabh Shahacf10202013-02-26 10:15:15 -08001144 ALOGD_IF(isDebug(),"%s: MDP Comp: Drawing layer: %p hnd: %p \
Jeykumar Sankaran85977e32013-02-25 17:06:08 -08001145 using pipe: %d", __FUNCTION__, layer, hnd, indexR );
Saurabh Shahacf10202013-02-26 10:15:15 -08001146 if (!ov.queueBuffer(fd, offset, destR)) {
1147 ALOGE("%s: queueBuffer failed for right mixer", __FUNCTION__);
1148 return false;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001149 }
1150 }
Saurabh Shahacf10202013-02-26 10:15:15 -08001151
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001152 layerProp[i].mFlags &= ~HWC_MDPCOMP;
1153 }
Saurabh Shahacf10202013-02-26 10:15:15 -08001154
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08001155 return true;
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001156}
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001157}; //namespace
1158