blob: c7335237a31561698c9fa57dd335ddedaae5620e [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];
Ramkumar Radhakrishnan3686b7e2014-03-17 17:30:15 -070069 mModeOn = prepare(ctx, list, layer->displayFrame, fbZorder) &&
Saurabh Shaha36be922013-12-16 18:18:39 -080070 ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd);
Ramkumar Radhakrishnan3686b7e2014-03-17 17:30:15 -070071 return mModeOn;
Saurabh Shaha36be922013-12-16 18:18:39 -080072}
73
Saurabh Shahcf053c62012-12-13 12:32:55 -080074//================= Low res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -070075FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy):
76 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -080077
Saurabh Shah220a30c2013-10-29 16:12:12 -070078void FBUpdateNonSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080079 IFBUpdate::reset();
80 mDest = ovutils::OV_INVALID;
81}
82
Saurabh Shah88e4d272013-09-03 13:31:29 -070083bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053084 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070085 ovutils::Whf &info,
86 hwc_rect_t& sourceCrop,
87 ovutils::eMdpFlags& mdpFlags,
88 int& rotFlags)
89{
90 int extOrient = getExtOrientation(ctx);
91 ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient);
92 if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
93 mRot = ctx->mRotMgr->getNext();
94 if(mRot == NULL) return false;
Saurabh Shah39240c92014-03-31 10:31:42 -070095 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080096 // Composed FB content will have black bars, if the viewFrame of the
97 // external is different from {0, 0, fbWidth, fbHeight}, so intersect
98 // viewFrame with sourceCrop to avoid those black bars
99 sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700100 //Configure rotator for pre-rotation
101 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
102 ALOGE("%s: configRotator Failed!", __FUNCTION__);
103 mRot = NULL;
104 return false;
105 }
106 info.format = (mRot)->getDstFormat();
107 updateSource(orient, info, sourceCrop);
108 rotFlags |= ovutils::ROT_PREROTATED;
109 }
110 return true;
111}
112
Saurabh Shah88e4d272013-09-03 13:31:29 -0700113bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800114 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500115 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800116 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800117 __FUNCTION__);
118 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500119 }
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800120 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800121 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500122}
123
124// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700125bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800126 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500127 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500128 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500129 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800130 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
131 // ext only layer present..
132 if(extOnlyLayerIndex != -1) {
133 layer = &list->hwLayers[extOnlyLayerIndex];
134 layer->compositionType = HWC_OVERLAY;
135 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500136 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700137
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700138 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
139 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
140 mTileEnabled));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500141
Saurabh Shahc62f3982014-03-05 14:28:26 -0800142 Overlay::PipeSpecs pipeSpecs;
143 pipeSpecs.formatClass = Overlay::FORMAT_RGB;
144 pipeSpecs.needsScaling = qhwc::needsScaling(layer);
145 pipeSpecs.dpy = mDpy;
146 pipeSpecs.mixer = Overlay::MIXER_DEFAULT;
147 pipeSpecs.fb = true;
148
149 ovutils::eDest dest = ov.getPipe(pipeSpecs);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500150 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700151 ALOGE("%s: No pipes available to configure fb for dpy %d",
152 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500153 return false;
154 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800155 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500156
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700157 if((mDpy && ctx->deviceOrientation) &&
158 ctx->listStats[mDpy].isDisplayAnimating) {
159 fbZorder = 0;
160 }
161
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800162 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700163 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800164 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500165
Saurabh Shah62e1d732013-09-17 10:44:05 -0700166 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800167 hwc_rect_t displayFrame = layer->displayFrame;
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800168
169 // No FB update optimization on (1) Custom FB resolution,
170 // (2) External Mirror mode, (3) External orientation
171 if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode
172 && !ctx->mExtOrientation) {
173 sourceCrop = fbUpdatingRect;
174 displayFrame = fbUpdatingRect;
175 }
176
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700177 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700178 int rotFlags = ovutils::ROT_FLAGS_NONE;
179
180 ovutils::eTransform orient =
181 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700182 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700183 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700184
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700185 // Do not use getNonWormholeRegion() function to calculate the
186 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700187 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700188 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700189 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
190 sourceCrop = layer->displayFrame;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700191 } else if((!mDpy ||
Dileep Kumar Reddibf2678b2014-01-29 15:33:32 +0530192 (mDpy && !extOrient
193 && !ctx->dpyAttr[mDpy].mDownScaleMode))
194 && (extOnlyLayerIndex == -1)) {
195 if(!qdutils::MDPVersion::getInstance().is8x26() &&
196 !ctx->dpyAttr[mDpy].customFBSize) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700197 getNonWormholeRegion(list, sourceCrop);
198 displayFrame = sourceCrop;
199 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800200 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700201 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700202 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800203 //Store the displayFrame, will be used in getDisplayViewFrame
204 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700205 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700206 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530207 ret = preRotateExtDisplay(ctx, layer, info,
208 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700209 if(!ret) {
210 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
211 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);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500225 ret = false;
226 }
227 }
228 return ret;
229}
230
Saurabh Shah88e4d272013-09-03 13:31:29 -0700231bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500232{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800233 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500234 return true;
235 }
236 bool ret = true;
237 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800238 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700239 int fd = hnd->fd;
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530240 uint32_t offset = (uint32_t)hnd->offset;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700241 if(mRot) {
242 if(!mRot->queueBuffer(fd, offset))
243 return false;
244 fd = mRot->getDstMemId();
245 offset = mRot->getDstOffset();
246 }
247 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800248 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500249 ret = false;
250 }
251 return ret;
252}
253
Saurabh Shahcf053c62012-12-13 12:32:55 -0800254//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700255FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
256 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800257
Saurabh Shah220a30c2013-10-29 16:12:12 -0700258void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800259 IFBUpdate::reset();
260 mDestLeft = ovutils::OV_INVALID;
261 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700262 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800263}
264
Saurabh Shah88e4d272013-09-03 13:31:29 -0700265bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800266 hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800267 if(!ctx->mMDP.hasOverlay) {
268 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800269 __FUNCTION__);
270 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800271 }
272 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800273 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800274 return mModeOn;
275}
276
277// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700278bool FBUpdateSplit::configure(hwc_context_t *ctx,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800279 hwc_display_contents_1 *list, hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800280 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500281 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800282 if (LIKELY(ctx->mOverlay)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800283 /* External only layer present */
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800284 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800285 if(extOnlyLayerIndex != -1) {
286 layer = &list->hwLayers[extOnlyLayerIndex];
287 layer->compositionType = HWC_OVERLAY;
288 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800289 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
290 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
291 mTileEnabled));
292
Saurabh Shahcf053c62012-12-13 12:32:55 -0800293 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800294 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800295 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800296 ovutils::eTransform orient =
297 static_cast<ovutils::eTransform>(layer->transform);
298 const int hw_w = ctx->dpyAttr[mDpy].xres;
299 const int hw_h = ctx->dpyAttr[mDpy].yres;
300 const int lSplit = getLeftSplit(ctx, mDpy);
301 mDestLeft = ovutils::OV_INVALID;
302 mDestRight = ovutils::OV_INVALID;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800303
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800304 hwc_rect_t sourceCrop = fbUpdatingRect;
305 hwc_rect_t displayFrame = fbUpdatingRect;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700306
Saurabh Shahcf053c62012-12-13 12:32:55 -0800307 ret = true;
Saurabh Shahc62f3982014-03-05 14:28:26 -0800308 Overlay::PipeSpecs pipeSpecs;
309 pipeSpecs.formatClass = Overlay::FORMAT_RGB;
310 pipeSpecs.needsScaling = qhwc::needsScaling(layer);
311 pipeSpecs.dpy = mDpy;
312 pipeSpecs.fb = true;
313
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800314 /* Configure left pipe */
315 if(displayFrame.left < lSplit) {
Saurabh Shahc62f3982014-03-05 14:28:26 -0800316 pipeSpecs.mixer = Overlay::MIXER_LEFT;
317 ovutils::eDest destL = ov.getPipe(pipeSpecs);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800318 if(destL == ovutils::OV_INVALID) { //None available
319 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
320 " mixer", __FUNCTION__, mDpy);
321 return false;
322 }
323
324 mDestLeft = destL;
325
326 //XXX: FB layer plane alpha is currently sent as zero from
327 //surfaceflinger
328 ovutils::PipeArgs pargL(mdpFlags,
329 info,
330 zOrder,
331 ovutils::IS_FG_OFF,
332 ovutils::ROT_FLAGS_NONE,
333 ovutils::DEFAULT_PLANE_ALPHA,
334 (ovutils::eBlending)
335 getBlending(layer->blending));
336 hwc_rect_t cropL = sourceCrop;
337 hwc_rect_t dstL = displayFrame;
338 hwc_rect_t scissorL = {0, 0, lSplit, hw_h };
339 qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0);
340
341 if (configMdp(ctx->mOverlay, pargL, orient, cropL,
342 dstL, NULL, destL)< 0) {
343 ALOGE("%s: configMdp fails for left FB", __FUNCTION__);
344 ret = false;
345 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800346 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800347
348 /* Configure right pipe */
349 if(displayFrame.right > lSplit) {
Saurabh Shahc62f3982014-03-05 14:28:26 -0800350 pipeSpecs.mixer = Overlay::MIXER_RIGHT;
351 ovutils::eDest destR = ov.getPipe(pipeSpecs);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800352 if(destR == ovutils::OV_INVALID) { //None available
353 ALOGE("%s: No pipes available to configure fb for dpy %d's"
354 " right mixer", __FUNCTION__, mDpy);
355 return false;
356 }
357
358 mDestRight = destR;
359 ovutils::eMdpFlags mdpFlagsR = mdpFlags;
360 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
361
362 //XXX: FB layer plane alpha is currently sent as zero from
363 //surfaceflinger
364 ovutils::PipeArgs pargR(mdpFlagsR,
365 info,
366 zOrder,
367 ovutils::IS_FG_OFF,
368 ovutils::ROT_FLAGS_NONE,
369 ovutils::DEFAULT_PLANE_ALPHA,
370 (ovutils::eBlending)
371 getBlending(layer->blending));
372
373 hwc_rect_t cropR = sourceCrop;
374 hwc_rect_t dstR = displayFrame;
375 hwc_rect_t scissorR = {lSplit, 0, hw_w, hw_h };
376 qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0);
377
378 dstR.left -= lSplit;
379 dstR.right -= lSplit;
380
381 if (configMdp(ctx->mOverlay, pargR, orient, cropR,
382 dstR, NULL, destR) < 0) {
383 ALOGE("%s: configMdp fails for right FB", __FUNCTION__);
384 ret = false;
385 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800386 }
387 }
388 return ret;
389}
390
Saurabh Shah88e4d272013-09-03 13:31:29 -0700391bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800392{
393 if(!mModeOn) {
394 return true;
395 }
396 bool ret = true;
397 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800398 if(mDestLeft != ovutils::OV_INVALID) {
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530399 if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestLeft)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800400 ALOGE("%s: queue failed for left of dpy = %d",
401 __FUNCTION__, mDpy);
402 ret = false;
403 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800404 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800405 if(mDestRight != ovutils::OV_INVALID) {
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530406 if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestRight)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800407 ALOGE("%s: queue failed for right of dpy = %d",
408 __FUNCTION__, mDpy);
409 ret = false;
410 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800411 }
412 return ret;
413}
414
Saurabh Shahab47c692014-02-12 18:45:57 -0800415//=================FBSrcSplit====================================
416FBSrcSplit::FBSrcSplit(hwc_context_t *ctx, const int& dpy):
417 FBUpdateSplit(ctx, dpy) {}
418
419bool FBSrcSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
420 hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahab47c692014-02-12 18:45:57 -0800421 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 }
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800428
Saurabh Shahab47c692014-02-12 18:45:57 -0800429 overlay::Overlay& ov = *(ctx->mOverlay);
430
431 ovutils::Whf info(mAlignedFBWidth,
432 mAlignedFBHeight,
433 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
434 mTileEnabled));
Saurabh Shahab47c692014-02-12 18:45:57 -0800435
436 ovutils::eMdpFlags mdpFlags = OV_MDP_BLEND_FG_PREMULT;
437 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
438
439 ovutils::PipeArgs parg(mdpFlags,
440 info,
441 zOrder,
442 ovutils::IS_FG_OFF,
443 ovutils::ROT_FLAGS_NONE,
444 ovutils::DEFAULT_PLANE_ALPHA,
445 (ovutils::eBlending)
446 getBlending(layer->blending));
Saurabh Shahab47c692014-02-12 18:45:57 -0800447
448 int transform = layer->transform;
449 ovutils::eTransform orient =
450 static_cast<ovutils::eTransform>(transform);
Saurabh Shahab47c692014-02-12 18:45:57 -0800451
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800452 hwc_rect_t cropL = fbUpdatingRect;
453 hwc_rect_t cropR = fbUpdatingRect;
454
455 //Request left pipe (or 1 by default)
Saurabh Shahc62f3982014-03-05 14:28:26 -0800456 Overlay::PipeSpecs pipeSpecs;
457 pipeSpecs.formatClass = Overlay::FORMAT_RGB;
458 pipeSpecs.needsScaling = qhwc::needsScaling(layer);
459 pipeSpecs.dpy = mDpy;
460 pipeSpecs.mixer = Overlay::MIXER_DEFAULT;
461 pipeSpecs.fb = true;
462 ovutils::eDest destL = ov.getPipe(pipeSpecs);
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800463 if(destL == ovutils::OV_INVALID) {
464 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
465 " mixer", __FUNCTION__, mDpy);
466 return false;
Saurabh Shahab47c692014-02-12 18:45:57 -0800467 }
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800468
469 ovutils::eDest destR = ovutils::OV_INVALID;
470
471 //Request right pipe (2 pipes needed only if dim > 2048)
472 if((fbUpdatingRect.right - fbUpdatingRect.left) >
473 qdutils::MAX_DISPLAY_DIM) {
Saurabh Shahc62f3982014-03-05 14:28:26 -0800474 destR = ov.getPipe(pipeSpecs);
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800475 if(destR == ovutils::OV_INVALID) {
476 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
477 " mixer", __FUNCTION__, mDpy);
478 return false;
479 }
480
481 if(ctx->mOverlay->comparePipePriority(destL, destR) == -1) {
482 qhwc::swap(destL, destR);
483 }
484
485 //Split crop equally when using 2 pipes
486 cropL.right = (fbUpdatingRect.right + fbUpdatingRect.left) / 2;
487 cropR.left = cropL.right;
Saurabh Shahab47c692014-02-12 18:45:57 -0800488 }
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800489
490 mDestLeft = destL;
491 mDestRight = destR;
492
493 if(destL != OV_INVALID) {
494 if(configMdp(ctx->mOverlay, parg, orient,
495 cropL, cropL, NULL /*metadata*/, destL) < 0) {
496 ALOGE("%s: commit failed for left mixer config", __FUNCTION__);
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800497 return false;
498 }
Saurabh Shahab47c692014-02-12 18:45:57 -0800499 }
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800500
501 //configure right pipe
502 if(destR != OV_INVALID) {
503 if(configMdp(ctx->mOverlay, parg, orient,
504 cropR, cropR, NULL /*metadata*/, destR) < 0) {
505 ALOGE("%s: commit failed for right mixer config", __FUNCTION__);
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800506 return false;
507 }
508 }
509
510 return true;
Saurabh Shahab47c692014-02-12 18:45:57 -0800511}
512
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500513//---------------------------------------------------------------------
514}; //namespace qhwc