blob: 678eecbbdac28ed2fe4583b1cfdf5a28f046b3e6 [file] [log] [blame]
Naseer Ahmed758bfc52012-11-28 17:02:08 -05001/*
2 * Copyright (C) 2010 The Android Open Source Project
Dileep Kumar Reddibf2678b2014-01-29 15:33:32 +05303 * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved.
Naseer Ahmed758bfc52012-11-28 17:02:08 -05004 *
5 * Not a Contribution, Apache license notifications and license are
6 * retained for attribution purposes only.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
Saurabh Shahcf053c62012-12-13 12:32:55 -080021#define DEBUG_FBUPDATE 0
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070022#include <cutils/properties.h>
Naseer Ahmed758bfc52012-11-28 17:02:08 -050023#include <gralloc_priv.h>
Saurabh Shahaf5f5972013-07-30 13:56:35 -070024#include <overlay.h>
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070025#include <overlayRotator.h>
Naseer Ahmed758bfc52012-11-28 17:02:08 -050026#include "hwc_fbupdate.h"
Saurabh Shahbd2d0832013-04-04 14:33:08 -070027#include "mdp_version.h"
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070028#include "external.h"
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -070029#include "virtual.h"
Saurabh Shahbd2d0832013-04-04 14:33:08 -070030
31using namespace qdutils;
Saurabh Shahaf5f5972013-07-30 13:56:35 -070032using namespace overlay;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070033using overlay::Rotator;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -070034using namespace overlay::utils;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070035
Naseer Ahmed758bfc52012-11-28 17:02:08 -050036namespace qhwc {
37
38namespace ovutils = overlay::utils;
39
Saurabh Shah88e4d272013-09-03 13:31:29 -070040IFBUpdate* IFBUpdate::getObject(hwc_context_t *ctx, const int& dpy) {
41 if(isDisplaySplit(ctx, dpy)) {
Saurabh Shahab47c692014-02-12 18:45:57 -080042 if(qdutils::MDPVersion::getInstance().isSrcSplit()) {
43 return new FBSrcSplit(ctx, dpy);
44 }
Saurabh Shah220a30c2013-10-29 16:12:12 -070045 return new FBUpdateSplit(ctx, dpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -080046 }
Saurabh Shah220a30c2013-10-29 16:12:12 -070047 return new FBUpdateNonSplit(ctx, dpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050048}
49
Saurabh Shah220a30c2013-10-29 16:12:12 -070050IFBUpdate::IFBUpdate(hwc_context_t *ctx, const int& dpy) : mDpy(dpy) {
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -080051 size_t size = 0;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070052 getBufferAttributes(ctx->dpyAttr[mDpy].xres,
53 ctx->dpyAttr[mDpy].yres,
Saurabh Shah220a30c2013-10-29 16:12:12 -070054 HAL_PIXEL_FORMAT_RGBA_8888,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070055 0,
Saurabh Shah220a30c2013-10-29 16:12:12 -070056 mAlignedFBWidth,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070057 mAlignedFBHeight,
58 mTileEnabled, size);
Saurabh Shah220a30c2013-10-29 16:12:12 -070059}
60
61void IFBUpdate::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080062 mModeOn = false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070063 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -080064}
65
Saurabh Shaha36be922013-12-16 18:18:39 -080066bool IFBUpdate::prepareAndValidate(hwc_context_t *ctx,
67 hwc_display_contents_1 *list, int fbZorder) {
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -080068 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
69 return prepare(ctx, list, layer->displayFrame, fbZorder) &&
Saurabh Shaha36be922013-12-16 18:18:39 -080070 ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd);
71}
72
Saurabh Shahcf053c62012-12-13 12:32:55 -080073//================= Low res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -070074FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy):
75 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -080076
Saurabh Shah220a30c2013-10-29 16:12:12 -070077void FBUpdateNonSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080078 IFBUpdate::reset();
79 mDest = ovutils::OV_INVALID;
80}
81
Saurabh Shah88e4d272013-09-03 13:31:29 -070082bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053083 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070084 ovutils::Whf &info,
85 hwc_rect_t& sourceCrop,
86 ovutils::eMdpFlags& mdpFlags,
87 int& rotFlags)
88{
89 int extOrient = getExtOrientation(ctx);
90 ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient);
91 if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
92 mRot = ctx->mRotMgr->getNext();
93 if(mRot == NULL) return false;
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080094 // Composed FB content will have black bars, if the viewFrame of the
95 // external is different from {0, 0, fbWidth, fbHeight}, so intersect
96 // viewFrame with sourceCrop to avoid those black bars
97 sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070098 //Configure rotator for pre-rotation
99 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
100 ALOGE("%s: configRotator Failed!", __FUNCTION__);
101 mRot = NULL;
102 return false;
103 }
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -0800104 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700105 info.format = (mRot)->getDstFormat();
106 updateSource(orient, info, sourceCrop);
107 rotFlags |= ovutils::ROT_PREROTATED;
108 }
109 return true;
110}
111
Saurabh Shah88e4d272013-09-03 13:31:29 -0700112bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800113 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500114 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800115 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800116 __FUNCTION__);
117 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500118 }
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800119 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800120 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500121}
122
123// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700124bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800125 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500126 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500127 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500128 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800129 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
130 // ext only layer present..
131 if(extOnlyLayerIndex != -1) {
132 layer = &list->hwLayers[extOnlyLayerIndex];
133 layer->compositionType = HWC_OVERLAY;
134 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500135 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700136
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700137 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
138 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
139 mTileEnabled));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500140
Saurabh Shahd4e65852013-06-17 11:33:53 -0700141 //Request a pipe
142 ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
143 if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) {
144 //For 8x26 external always use DMA pipe
145 type = ovutils::OV_MDP_PIPE_DMA;
146 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700147 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500148 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700149 ALOGE("%s: No pipes available to configure fb for dpy %d",
150 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500151 return false;
152 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800153 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500154
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700155 if((mDpy && ctx->deviceOrientation) &&
156 ctx->listStats[mDpy].isDisplayAnimating) {
157 fbZorder = 0;
158 }
159
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800160 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700161 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800162 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500163
Saurabh Shah62e1d732013-09-17 10:44:05 -0700164 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800165 hwc_rect_t displayFrame = layer->displayFrame;
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800166
167 // No FB update optimization on (1) Custom FB resolution,
168 // (2) External Mirror mode, (3) External orientation
169 if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode
170 && !ctx->mExtOrientation) {
171 sourceCrop = fbUpdatingRect;
172 displayFrame = fbUpdatingRect;
173 }
174
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700175 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700176 int rotFlags = ovutils::ROT_FLAGS_NONE;
177
178 ovutils::eTransform orient =
179 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700180 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700181 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700182
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700183 // Do not use getNonWormholeRegion() function to calculate the
184 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700185 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700186 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700187 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
188 sourceCrop = layer->displayFrame;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700189 } else if((!mDpy ||
Dileep Kumar Reddibf2678b2014-01-29 15:33:32 +0530190 (mDpy && !extOrient
191 && !ctx->dpyAttr[mDpy].mDownScaleMode))
192 && (extOnlyLayerIndex == -1)) {
193 if(!qdutils::MDPVersion::getInstance().is8x26() &&
194 !ctx->dpyAttr[mDpy].customFBSize) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700195 getNonWormholeRegion(list, sourceCrop);
196 displayFrame = sourceCrop;
197 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800198 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700199 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700200 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800201 //Store the displayFrame, will be used in getDisplayViewFrame
202 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700203 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700204 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530205 ret = preRotateExtDisplay(ctx, layer, info,
206 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700207 if(!ret) {
208 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800209 ctx->mOverlay->clear(mDpy);
210 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700211 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700212 }
213 //For the mdp, since either we are pre-rotating or MDP does flips
214 orient = ovutils::OVERLAY_TRANSFORM_0;
215 transform = 0;
216 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400217 static_cast<ovutils::eRotFlags>(rotFlags),
218 ovutils::DEFAULT_PLANE_ALPHA,
219 (ovutils::eBlending)
220 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500221 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700222 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
223 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700224 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800225 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500226 ret = false;
227 }
228 }
229 return ret;
230}
231
Saurabh Shah88e4d272013-09-03 13:31:29 -0700232bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500233{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800234 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500235 return true;
236 }
237 bool ret = true;
238 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800239 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700240 int fd = hnd->fd;
241 uint32_t offset = hnd->offset;
242 if(mRot) {
243 if(!mRot->queueBuffer(fd, offset))
244 return false;
245 fd = mRot->getDstMemId();
246 offset = mRot->getDstOffset();
247 }
248 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800249 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500250 ret = false;
251 }
252 return ret;
253}
254
Saurabh Shahcf053c62012-12-13 12:32:55 -0800255//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700256FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
257 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800258
Saurabh Shah220a30c2013-10-29 16:12:12 -0700259void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800260 IFBUpdate::reset();
261 mDestLeft = ovutils::OV_INVALID;
262 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700263 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800264}
265
Saurabh Shah88e4d272013-09-03 13:31:29 -0700266bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800267 hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800268 if(!ctx->mMDP.hasOverlay) {
269 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800270 __FUNCTION__);
271 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800272 }
273 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800274 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800275 return mModeOn;
276}
277
278// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700279bool FBUpdateSplit::configure(hwc_context_t *ctx,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800280 hwc_display_contents_1 *list, hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800281 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500282 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800283 if (LIKELY(ctx->mOverlay)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800284 /* External only layer present */
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800285 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800286 if(extOnlyLayerIndex != -1) {
287 layer = &list->hwLayers[extOnlyLayerIndex];
288 layer->compositionType = HWC_OVERLAY;
289 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800290 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
291 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
292 mTileEnabled));
293
Saurabh Shahcf053c62012-12-13 12:32:55 -0800294 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800295 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800296 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800297 ovutils::eTransform orient =
298 static_cast<ovutils::eTransform>(layer->transform);
299 const int hw_w = ctx->dpyAttr[mDpy].xres;
300 const int hw_h = ctx->dpyAttr[mDpy].yres;
301 const int lSplit = getLeftSplit(ctx, mDpy);
302 mDestLeft = ovutils::OV_INVALID;
303 mDestRight = ovutils::OV_INVALID;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800304
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800305 hwc_rect_t sourceCrop = fbUpdatingRect;
306 hwc_rect_t displayFrame = fbUpdatingRect;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700307
Saurabh Shahcf053c62012-12-13 12:32:55 -0800308 ret = true;
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800309 /* Configure left pipe */
310 if(displayFrame.left < lSplit) {
311 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
312 Overlay::MIXER_LEFT);
313 if(destL == ovutils::OV_INVALID) { //None available
314 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
315 " mixer", __FUNCTION__, mDpy);
316 return false;
317 }
318
319 mDestLeft = destL;
320
321 //XXX: FB layer plane alpha is currently sent as zero from
322 //surfaceflinger
323 ovutils::PipeArgs pargL(mdpFlags,
324 info,
325 zOrder,
326 ovutils::IS_FG_OFF,
327 ovutils::ROT_FLAGS_NONE,
328 ovutils::DEFAULT_PLANE_ALPHA,
329 (ovutils::eBlending)
330 getBlending(layer->blending));
331 hwc_rect_t cropL = sourceCrop;
332 hwc_rect_t dstL = displayFrame;
333 hwc_rect_t scissorL = {0, 0, lSplit, hw_h };
334 qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0);
335
336 if (configMdp(ctx->mOverlay, pargL, orient, cropL,
337 dstL, NULL, destL)< 0) {
338 ALOGE("%s: configMdp fails for left FB", __FUNCTION__);
339 ret = false;
340 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800341 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800342
343 /* Configure right pipe */
344 if(displayFrame.right > lSplit) {
345 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
346 Overlay::MIXER_RIGHT);
347 if(destR == ovutils::OV_INVALID) { //None available
348 ALOGE("%s: No pipes available to configure fb for dpy %d's"
349 " right mixer", __FUNCTION__, mDpy);
350 return false;
351 }
352
353 mDestRight = destR;
354 ovutils::eMdpFlags mdpFlagsR = mdpFlags;
355 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
356
357 //XXX: FB layer plane alpha is currently sent as zero from
358 //surfaceflinger
359 ovutils::PipeArgs pargR(mdpFlagsR,
360 info,
361 zOrder,
362 ovutils::IS_FG_OFF,
363 ovutils::ROT_FLAGS_NONE,
364 ovutils::DEFAULT_PLANE_ALPHA,
365 (ovutils::eBlending)
366 getBlending(layer->blending));
367
368 hwc_rect_t cropR = sourceCrop;
369 hwc_rect_t dstR = displayFrame;
370 hwc_rect_t scissorR = {lSplit, 0, hw_w, hw_h };
371 qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0);
372
373 dstR.left -= lSplit;
374 dstR.right -= lSplit;
375
376 if (configMdp(ctx->mOverlay, pargR, orient, cropR,
377 dstR, NULL, destR) < 0) {
378 ALOGE("%s: configMdp fails for right FB", __FUNCTION__);
379 ret = false;
380 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800381 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800382
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800383 if(ret == false) {
384 ctx->mLayerRotMap[mDpy]->clear();
385 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800386 }
387 return ret;
388}
389
Saurabh Shah88e4d272013-09-03 13:31:29 -0700390bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800391{
392 if(!mModeOn) {
393 return true;
394 }
395 bool ret = true;
396 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800397 if(mDestLeft != ovutils::OV_INVALID) {
398 if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestLeft)) {
399 ALOGE("%s: queue failed for left of dpy = %d",
400 __FUNCTION__, mDpy);
401 ret = false;
402 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800403 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800404 if(mDestRight != ovutils::OV_INVALID) {
405 if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestRight)) {
406 ALOGE("%s: queue failed for right of dpy = %d",
407 __FUNCTION__, mDpy);
408 ret = false;
409 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800410 }
411 return ret;
412}
413
Saurabh Shahab47c692014-02-12 18:45:57 -0800414//=================FBSrcSplit====================================
415FBSrcSplit::FBSrcSplit(hwc_context_t *ctx, const int& dpy):
416 FBUpdateSplit(ctx, dpy) {}
417
418bool FBSrcSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
419 hwc_rect_t fbUpdatingRect, int fbZorder) {
420 bool ret = false;
421 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
422 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
423 // ext only layer present..
424 if(extOnlyLayerIndex != -1) {
425 layer = &list->hwLayers[extOnlyLayerIndex];
426 layer->compositionType = HWC_OVERLAY;
427 }
428 overlay::Overlay& ov = *(ctx->mOverlay);
429
430 ovutils::Whf info(mAlignedFBWidth,
431 mAlignedFBHeight,
432 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
433 mTileEnabled));
434 //Request left pipe, VG first owing to higher prio
435 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy,
436 Overlay::MIXER_DEFAULT);
437 if(destL == ovutils::OV_INVALID) {
438 destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
439 Overlay::MIXER_DEFAULT);
440 if(destL == ovutils::OV_INVALID) {
441 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
442 " mixer", __FUNCTION__, mDpy);
443 return false;
444 }
445 }
446 //Request right pipe
447 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
448 Overlay::MIXER_DEFAULT);
449 if(destR == ovutils::OV_INVALID) {
450 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
451 " mixer", __FUNCTION__, mDpy);
452 return false;
453 }
454
455 mDestLeft = destL;
456 mDestRight = destR;
457
458 ovutils::eMdpFlags mdpFlags = OV_MDP_BLEND_FG_PREMULT;
459 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
460
461 ovutils::PipeArgs parg(mdpFlags,
462 info,
463 zOrder,
464 ovutils::IS_FG_OFF,
465 ovutils::ROT_FLAGS_NONE,
466 ovutils::DEFAULT_PLANE_ALPHA,
467 (ovutils::eBlending)
468 getBlending(layer->blending));
469 ov.setSource(parg, destL);
470 ov.setSource(parg, destR);
471
472 //Crop and Position are same for FB
473 ovutils::Dim cropPosL(
474 fbUpdatingRect.left,
475 fbUpdatingRect.top,
476 (fbUpdatingRect.right - fbUpdatingRect.left) / 2,
477 fbUpdatingRect.bottom - fbUpdatingRect.top);
478
479 ovutils::Dim cropPosR(
480 cropPosL.x + cropPosL.w,
481 cropPosL.y,
482 cropPosL.w,
483 cropPosL.h);
484
485 ov.setCrop(cropPosL, destL);
486 ov.setCrop(cropPosR, destR);
487 ov.setPosition(cropPosL, destL);
488 ov.setPosition(cropPosR, destR);
489
490 int transform = layer->transform;
491 ovutils::eTransform orient =
492 static_cast<ovutils::eTransform>(transform);
493 ov.setTransform(orient, destL);
494 ov.setTransform(orient, destR);
495
496 ret = true;
497 if (!ov.commit(destL)) {
498 ALOGE("%s: commit fails for left", __FUNCTION__);
499 ret = false;
500 }
501 if (!ov.commit(destR)) {
502 ALOGE("%s: commit fails for right", __FUNCTION__);
503 ret = false;
504 }
505 if(ret == false) {
506 ctx->mLayerRotMap[mDpy]->clear();
507 }
508 return ret;
509}
510
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500511//---------------------------------------------------------------------
512}; //namespace qhwc