blob: 27abf6acd148a670853ae9293559643d5b7a3a10 [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)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800284 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
285 // ext only layer present..
286 if(extOnlyLayerIndex != -1) {
287 layer = &list->hwLayers[extOnlyLayerIndex];
288 layer->compositionType = HWC_OVERLAY;
289 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800290 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700291
292 ovutils::Whf info(mAlignedFBWidth,
293 mAlignedFBHeight,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700294 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
295 mTileEnabled));
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700296 //Request left pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700297 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
298 Overlay::MIXER_LEFT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800299 if(destL == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700300 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
301 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800302 return false;
303 }
Saurabh Shahc66f54d2013-06-12 15:45:59 -0700304 //Request right pipe
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700305 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
306 Overlay::MIXER_RIGHT);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800307 if(destR == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700308 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
309 " mixer", __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800310 return false;
311 }
312
313 mDestLeft = destL;
314 mDestRight = destR;
315
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800316 ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT;
Sravan Kumar D.V.Nb5ed0292013-03-15 08:51:16 +0530317
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800318 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800319
Naseer Ahmed522ce662013-03-18 20:14:05 -0400320 //XXX: FB layer plane alpha is currently sent as zero from
321 //surfaceflinger
Saurabh Shahcf053c62012-12-13 12:32:55 -0800322 ovutils::PipeArgs pargL(mdpFlagsL,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800323 info,
324 zOrder,
325 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400326 ovutils::ROT_FLAGS_NONE,
327 ovutils::DEFAULT_PLANE_ALPHA,
328 (ovutils::eBlending)
329 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800330 ov.setSource(pargL, destL);
331
332 ovutils::eMdpFlags mdpFlagsR = mdpFlagsL;
333 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
334 ovutils::PipeArgs pargR(mdpFlagsR,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800335 info,
336 zOrder,
337 ovutils::IS_FG_OFF,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400338 ovutils::ROT_FLAGS_NONE,
339 ovutils::DEFAULT_PLANE_ALPHA,
340 (ovutils::eBlending)
341 getBlending(layer->blending));
Saurabh Shahcf053c62012-12-13 12:32:55 -0800342 ov.setSource(pargR, destR);
343
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800344 hwc_rect_t sourceCrop = fbUpdatingRect;
345 hwc_rect_t displayFrame = fbUpdatingRect;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700346
347 const float xres = ctx->dpyAttr[mDpy].xres;
Saurabh Shah07a8ca82013-08-06 18:45:42 -0700348 const int lSplit = getLeftSplit(ctx, mDpy);
Saurabh Shah67a38c32013-06-10 16:23:15 -0700349 const float lSplitRatio = lSplit / xres;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700350 const float lCropWidth =
351 (sourceCrop.right - sourceCrop.left) * lSplitRatio;
352
353 ovutils::Dim dcropL(
354 sourceCrop.left,
355 sourceCrop.top,
356 lCropWidth,
357 sourceCrop.bottom - sourceCrop.top);
358
Saurabh Shahcf053c62012-12-13 12:32:55 -0800359 ovutils::Dim dcropR(
Saurabh Shah67a38c32013-06-10 16:23:15 -0700360 sourceCrop.left + lCropWidth,
361 sourceCrop.top,
362 (sourceCrop.right - sourceCrop.left) - lCropWidth,
363 sourceCrop.bottom - sourceCrop.top);
364
Saurabh Shahcf053c62012-12-13 12:32:55 -0800365 ov.setCrop(dcropL, destL);
366 ov.setCrop(dcropR, destR);
367
368 int transform = layer->transform;
369 ovutils::eTransform orient =
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800370 static_cast<ovutils::eTransform>(transform);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800371 ov.setTransform(orient, destL);
372 ov.setTransform(orient, destR);
373
Saurabh Shah67a38c32013-06-10 16:23:15 -0700374 const int lWidth = (lSplit - displayFrame.left);
375 const int rWidth = (displayFrame.right - lSplit);
Saurabh Shahce416f02013-04-10 13:33:09 -0700376 const int height = displayFrame.bottom - displayFrame.top;
377
Saurabh Shah67a38c32013-06-10 16:23:15 -0700378 ovutils::Dim dposL(displayFrame.left,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800379 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700380 lWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700381 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700382 ov.setPosition(dposL, destL);
Saurabh Shahce416f02013-04-10 13:33:09 -0700383
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700384 ovutils::Dim dposR(0,
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800385 displayFrame.top,
Saurabh Shah67a38c32013-06-10 16:23:15 -0700386 rWidth,
Saurabh Shahce416f02013-04-10 13:33:09 -0700387 height);
Arun Kumar K.R0e8efb82013-03-18 17:31:50 -0700388 ov.setPosition(dposR, destR);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800389
390 ret = true;
391 if (!ov.commit(destL)) {
392 ALOGE("%s: commit fails for left", __FUNCTION__);
393 ret = false;
394 }
395 if (!ov.commit(destR)) {
396 ALOGE("%s: commit fails for right", __FUNCTION__);
397 ret = false;
398 }
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800399 if(ret == false) {
400 ctx->mLayerRotMap[mDpy]->clear();
401 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800402 }
403 return ret;
404}
405
Saurabh Shah88e4d272013-09-03 13:31:29 -0700406bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800407{
408 if(!mModeOn) {
409 return true;
410 }
411 bool ret = true;
412 overlay::Overlay& ov = *(ctx->mOverlay);
413 ovutils::eDest destL = mDestLeft;
414 ovutils::eDest destR = mDestRight;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800415 if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) {
416 ALOGE("%s: queue failed for left of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800417 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800418 ret = false;
419 }
420 if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) {
421 ALOGE("%s: queue failed for right of dpy = %d",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800422 __FUNCTION__, mDpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800423 ret = false;
424 }
425 return ret;
426}
427
Saurabh Shahab47c692014-02-12 18:45:57 -0800428//=================FBSrcSplit====================================
429FBSrcSplit::FBSrcSplit(hwc_context_t *ctx, const int& dpy):
430 FBUpdateSplit(ctx, dpy) {}
431
432bool FBSrcSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
433 hwc_rect_t fbUpdatingRect, int fbZorder) {
434 bool ret = false;
435 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
436 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
437 // ext only layer present..
438 if(extOnlyLayerIndex != -1) {
439 layer = &list->hwLayers[extOnlyLayerIndex];
440 layer->compositionType = HWC_OVERLAY;
441 }
442 overlay::Overlay& ov = *(ctx->mOverlay);
443
444 ovutils::Whf info(mAlignedFBWidth,
445 mAlignedFBHeight,
446 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
447 mTileEnabled));
448 //Request left pipe, VG first owing to higher prio
449 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy,
450 Overlay::MIXER_DEFAULT);
451 if(destL == ovutils::OV_INVALID) {
452 destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
453 Overlay::MIXER_DEFAULT);
454 if(destL == ovutils::OV_INVALID) {
455 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
456 " mixer", __FUNCTION__, mDpy);
457 return false;
458 }
459 }
460 //Request right pipe
461 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
462 Overlay::MIXER_DEFAULT);
463 if(destR == ovutils::OV_INVALID) {
464 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
465 " mixer", __FUNCTION__, mDpy);
466 return false;
467 }
468
469 mDestLeft = destL;
470 mDestRight = destR;
471
472 ovutils::eMdpFlags mdpFlags = OV_MDP_BLEND_FG_PREMULT;
473 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
474
475 ovutils::PipeArgs parg(mdpFlags,
476 info,
477 zOrder,
478 ovutils::IS_FG_OFF,
479 ovutils::ROT_FLAGS_NONE,
480 ovutils::DEFAULT_PLANE_ALPHA,
481 (ovutils::eBlending)
482 getBlending(layer->blending));
483 ov.setSource(parg, destL);
484 ov.setSource(parg, destR);
485
486 //Crop and Position are same for FB
487 ovutils::Dim cropPosL(
488 fbUpdatingRect.left,
489 fbUpdatingRect.top,
490 (fbUpdatingRect.right - fbUpdatingRect.left) / 2,
491 fbUpdatingRect.bottom - fbUpdatingRect.top);
492
493 ovutils::Dim cropPosR(
494 cropPosL.x + cropPosL.w,
495 cropPosL.y,
496 cropPosL.w,
497 cropPosL.h);
498
499 ov.setCrop(cropPosL, destL);
500 ov.setCrop(cropPosR, destR);
501 ov.setPosition(cropPosL, destL);
502 ov.setPosition(cropPosR, destR);
503
504 int transform = layer->transform;
505 ovutils::eTransform orient =
506 static_cast<ovutils::eTransform>(transform);
507 ov.setTransform(orient, destL);
508 ov.setTransform(orient, destR);
509
510 ret = true;
511 if (!ov.commit(destL)) {
512 ALOGE("%s: commit fails for left", __FUNCTION__);
513 ret = false;
514 }
515 if (!ov.commit(destR)) {
516 ALOGE("%s: commit fails for right", __FUNCTION__);
517 ret = false;
518 }
519 if(ret == false) {
520 ctx->mLayerRotMap[mDpy]->clear();
521 }
522 return ret;
523}
524
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500525//---------------------------------------------------------------------
526}; //namespace qhwc