blob: b51b2eaa8cfdde97d9b9b76062ac7c6769ce8b18 [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;
radhakrishna2e792f92014-03-13 11:39:33 +0530143 if((qdutils::MDPVersion::getInstance().is8x26() ||
144 qdutils::MDPVersion::getInstance().is8x16()) && mDpy) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700145 //For 8x26 external always use DMA pipe
146 type = ovutils::OV_MDP_PIPE_DMA;
147 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700148 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500149 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700150 ALOGE("%s: No pipes available to configure fb for dpy %d",
151 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500152 return false;
153 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800154 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500155
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700156 if((mDpy && ctx->deviceOrientation) &&
157 ctx->listStats[mDpy].isDisplayAnimating) {
158 fbZorder = 0;
159 }
160
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800161 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700162 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800163 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500164
Saurabh Shah62e1d732013-09-17 10:44:05 -0700165 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800166 hwc_rect_t displayFrame = layer->displayFrame;
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800167
168 // No FB update optimization on (1) Custom FB resolution,
169 // (2) External Mirror mode, (3) External orientation
170 if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode
171 && !ctx->mExtOrientation) {
172 sourceCrop = fbUpdatingRect;
173 displayFrame = fbUpdatingRect;
174 }
175
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700176 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700177 int rotFlags = ovutils::ROT_FLAGS_NONE;
178
179 ovutils::eTransform orient =
180 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700181 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700182 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700183
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700184 // Do not use getNonWormholeRegion() function to calculate the
185 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700186 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700187 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700188 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
189 sourceCrop = layer->displayFrame;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700190 } else if((!mDpy ||
Dileep Kumar Reddibf2678b2014-01-29 15:33:32 +0530191 (mDpy && !extOrient
192 && !ctx->dpyAttr[mDpy].mDownScaleMode))
193 && (extOnlyLayerIndex == -1)) {
194 if(!qdutils::MDPVersion::getInstance().is8x26() &&
195 !ctx->dpyAttr[mDpy].customFBSize) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700196 getNonWormholeRegion(list, sourceCrop);
197 displayFrame = sourceCrop;
198 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800199 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700200 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700201 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800202 //Store the displayFrame, will be used in getDisplayViewFrame
203 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700204 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700205 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530206 ret = preRotateExtDisplay(ctx, layer, info,
207 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700208 if(!ret) {
209 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800210 ctx->mOverlay->clear(mDpy);
211 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700212 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700213 }
214 //For the mdp, since either we are pre-rotating or MDP does flips
215 orient = ovutils::OVERLAY_TRANSFORM_0;
216 transform = 0;
217 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400218 static_cast<ovutils::eRotFlags>(rotFlags),
219 ovutils::DEFAULT_PLANE_ALPHA,
220 (ovutils::eBlending)
221 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500222 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700223 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
224 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700225 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800226 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500227 ret = false;
228 }
229 }
230 return ret;
231}
232
Saurabh Shah88e4d272013-09-03 13:31:29 -0700233bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500234{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800235 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500236 return true;
237 }
238 bool ret = true;
239 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800240 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700241 int fd = hnd->fd;
Praveena Pachipulusud9443c72014-02-17 10:42:28 +0530242 uint32_t offset = (uint32_t)hnd->offset;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700243 if(mRot) {
244 if(!mRot->queueBuffer(fd, offset))
245 return false;
246 fd = mRot->getDstMemId();
247 offset = mRot->getDstOffset();
248 }
249 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800250 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500251 ret = false;
252 }
253 return ret;
254}
255
Saurabh Shahcf053c62012-12-13 12:32:55 -0800256//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700257FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
258 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800259
Saurabh Shah220a30c2013-10-29 16:12:12 -0700260void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800261 IFBUpdate::reset();
262 mDestLeft = ovutils::OV_INVALID;
263 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700264 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800265}
266
Saurabh Shah88e4d272013-09-03 13:31:29 -0700267bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800268 hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800269 if(!ctx->mMDP.hasOverlay) {
270 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800271 __FUNCTION__);
272 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800273 }
274 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800275 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800276 return mModeOn;
277}
278
279// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700280bool FBUpdateSplit::configure(hwc_context_t *ctx,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800281 hwc_display_contents_1 *list, hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800282 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500283 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800284 if (LIKELY(ctx->mOverlay)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800285 /* External only layer present */
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800286 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800287 if(extOnlyLayerIndex != -1) {
288 layer = &list->hwLayers[extOnlyLayerIndex];
289 layer->compositionType = HWC_OVERLAY;
290 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800291 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
292 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
293 mTileEnabled));
294
Saurabh Shahcf053c62012-12-13 12:32:55 -0800295 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800296 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800297 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800298 ovutils::eTransform orient =
299 static_cast<ovutils::eTransform>(layer->transform);
300 const int hw_w = ctx->dpyAttr[mDpy].xres;
301 const int hw_h = ctx->dpyAttr[mDpy].yres;
302 const int lSplit = getLeftSplit(ctx, mDpy);
303 mDestLeft = ovutils::OV_INVALID;
304 mDestRight = ovutils::OV_INVALID;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800305
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800306 hwc_rect_t sourceCrop = fbUpdatingRect;
307 hwc_rect_t displayFrame = fbUpdatingRect;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700308
Saurabh Shahcf053c62012-12-13 12:32:55 -0800309 ret = true;
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800310 /* Configure left pipe */
311 if(displayFrame.left < lSplit) {
312 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
313 Overlay::MIXER_LEFT);
314 if(destL == ovutils::OV_INVALID) { //None available
315 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
316 " mixer", __FUNCTION__, mDpy);
317 return false;
318 }
319
320 mDestLeft = destL;
321
322 //XXX: FB layer plane alpha is currently sent as zero from
323 //surfaceflinger
324 ovutils::PipeArgs pargL(mdpFlags,
325 info,
326 zOrder,
327 ovutils::IS_FG_OFF,
328 ovutils::ROT_FLAGS_NONE,
329 ovutils::DEFAULT_PLANE_ALPHA,
330 (ovutils::eBlending)
331 getBlending(layer->blending));
332 hwc_rect_t cropL = sourceCrop;
333 hwc_rect_t dstL = displayFrame;
334 hwc_rect_t scissorL = {0, 0, lSplit, hw_h };
335 qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0);
336
337 if (configMdp(ctx->mOverlay, pargL, orient, cropL,
338 dstL, NULL, destL)< 0) {
339 ALOGE("%s: configMdp fails for left FB", __FUNCTION__);
340 ret = false;
341 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800342 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800343
344 /* Configure right pipe */
345 if(displayFrame.right > lSplit) {
346 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
347 Overlay::MIXER_RIGHT);
348 if(destR == ovutils::OV_INVALID) { //None available
349 ALOGE("%s: No pipes available to configure fb for dpy %d's"
350 " right mixer", __FUNCTION__, mDpy);
351 return false;
352 }
353
354 mDestRight = destR;
355 ovutils::eMdpFlags mdpFlagsR = mdpFlags;
356 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
357
358 //XXX: FB layer plane alpha is currently sent as zero from
359 //surfaceflinger
360 ovutils::PipeArgs pargR(mdpFlagsR,
361 info,
362 zOrder,
363 ovutils::IS_FG_OFF,
364 ovutils::ROT_FLAGS_NONE,
365 ovutils::DEFAULT_PLANE_ALPHA,
366 (ovutils::eBlending)
367 getBlending(layer->blending));
368
369 hwc_rect_t cropR = sourceCrop;
370 hwc_rect_t dstR = displayFrame;
371 hwc_rect_t scissorR = {lSplit, 0, hw_w, hw_h };
372 qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0);
373
374 dstR.left -= lSplit;
375 dstR.right -= lSplit;
376
377 if (configMdp(ctx->mOverlay, pargR, orient, cropR,
378 dstR, NULL, destR) < 0) {
379 ALOGE("%s: configMdp fails for right FB", __FUNCTION__);
380 ret = false;
381 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800382 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800383
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800384 if(ret == false) {
385 ctx->mLayerRotMap[mDpy]->clear();
386 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800387 }
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) {
421 bool ret = false;
422 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
423 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
424 // ext only layer present..
425 if(extOnlyLayerIndex != -1) {
426 layer = &list->hwLayers[extOnlyLayerIndex];
427 layer->compositionType = HWC_OVERLAY;
428 }
429 overlay::Overlay& ov = *(ctx->mOverlay);
430
431 ovutils::Whf info(mAlignedFBWidth,
432 mAlignedFBHeight,
433 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
434 mTileEnabled));
435 //Request left pipe, VG first owing to higher prio
436 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_VG, mDpy,
437 Overlay::MIXER_DEFAULT);
438 if(destL == ovutils::OV_INVALID) {
439 destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
440 Overlay::MIXER_DEFAULT);
441 if(destL == ovutils::OV_INVALID) {
442 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
443 " mixer", __FUNCTION__, mDpy);
444 return false;
445 }
446 }
447 //Request right pipe
448 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
449 Overlay::MIXER_DEFAULT);
450 if(destR == ovutils::OV_INVALID) {
451 ALOGE("%s: No pipes available to configure fb for dpy %d's right"
452 " mixer", __FUNCTION__, mDpy);
453 return false;
454 }
455
456 mDestLeft = destL;
457 mDestRight = destR;
458
459 ovutils::eMdpFlags mdpFlags = OV_MDP_BLEND_FG_PREMULT;
460 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
461
462 ovutils::PipeArgs parg(mdpFlags,
463 info,
464 zOrder,
465 ovutils::IS_FG_OFF,
466 ovutils::ROT_FLAGS_NONE,
467 ovutils::DEFAULT_PLANE_ALPHA,
468 (ovutils::eBlending)
469 getBlending(layer->blending));
470 ov.setSource(parg, destL);
471 ov.setSource(parg, destR);
472
473 //Crop and Position are same for FB
474 ovutils::Dim cropPosL(
475 fbUpdatingRect.left,
476 fbUpdatingRect.top,
477 (fbUpdatingRect.right - fbUpdatingRect.left) / 2,
478 fbUpdatingRect.bottom - fbUpdatingRect.top);
479
480 ovutils::Dim cropPosR(
481 cropPosL.x + cropPosL.w,
482 cropPosL.y,
483 cropPosL.w,
484 cropPosL.h);
485
486 ov.setCrop(cropPosL, destL);
487 ov.setCrop(cropPosR, destR);
488 ov.setPosition(cropPosL, destL);
489 ov.setPosition(cropPosR, destR);
490
491 int transform = layer->transform;
492 ovutils::eTransform orient =
493 static_cast<ovutils::eTransform>(transform);
494 ov.setTransform(orient, destL);
495 ov.setTransform(orient, destR);
496
497 ret = true;
498 if (!ov.commit(destL)) {
499 ALOGE("%s: commit fails for left", __FUNCTION__);
500 ret = false;
501 }
502 if (!ov.commit(destR)) {
503 ALOGE("%s: commit fails for right", __FUNCTION__);
504 ret = false;
505 }
506 if(ret == false) {
507 ctx->mLayerRotMap[mDpy]->clear();
508 }
509 return ret;
510}
511
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500512//---------------------------------------------------------------------
513}; //namespace qhwc