blob: b1b71591da863410d932eebb01f2a944ac9fb0e5 [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 Shah220a30c2013-10-29 16:12:12 -070042 return new FBUpdateSplit(ctx, dpy);
Saurabh Shahcf053c62012-12-13 12:32:55 -080043 }
Saurabh Shah220a30c2013-10-29 16:12:12 -070044 return new FBUpdateNonSplit(ctx, dpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050045}
46
Saurabh Shah220a30c2013-10-29 16:12:12 -070047IFBUpdate::IFBUpdate(hwc_context_t *ctx, const int& dpy) : mDpy(dpy) {
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -080048 size_t size = 0;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070049 getBufferAttributes(ctx->dpyAttr[mDpy].xres,
50 ctx->dpyAttr[mDpy].yres,
Saurabh Shah220a30c2013-10-29 16:12:12 -070051 HAL_PIXEL_FORMAT_RGBA_8888,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070052 0,
Saurabh Shah220a30c2013-10-29 16:12:12 -070053 mAlignedFBWidth,
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070054 mAlignedFBHeight,
55 mTileEnabled, size);
Saurabh Shah220a30c2013-10-29 16:12:12 -070056}
57
58void IFBUpdate::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080059 mModeOn = false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -070060 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -080061}
62
Saurabh Shaha36be922013-12-16 18:18:39 -080063bool IFBUpdate::prepareAndValidate(hwc_context_t *ctx,
64 hwc_display_contents_1 *list, int fbZorder) {
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -080065 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
66 return prepare(ctx, list, layer->displayFrame, fbZorder) &&
Saurabh Shaha36be922013-12-16 18:18:39 -080067 ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd);
68}
69
Saurabh Shahcf053c62012-12-13 12:32:55 -080070//================= Low res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -070071FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy):
72 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -080073
Saurabh Shah220a30c2013-10-29 16:12:12 -070074void FBUpdateNonSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -080075 IFBUpdate::reset();
76 mDest = ovutils::OV_INVALID;
77}
78
Saurabh Shah88e4d272013-09-03 13:31:29 -070079bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx,
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +053080 hwc_layer_1_t *layer,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070081 ovutils::Whf &info,
82 hwc_rect_t& sourceCrop,
83 ovutils::eMdpFlags& mdpFlags,
84 int& rotFlags)
85{
86 int extOrient = getExtOrientation(ctx);
87 ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient);
88 if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
89 mRot = ctx->mRotMgr->getNext();
90 if(mRot == NULL) return false;
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -080091 // Composed FB content will have black bars, if the viewFrame of the
92 // external is different from {0, 0, fbWidth, fbHeight}, so intersect
93 // viewFrame with sourceCrop to avoid those black bars
94 sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -070095 //Configure rotator for pre-rotation
96 if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) {
97 ALOGE("%s: configRotator Failed!", __FUNCTION__);
98 mRot = NULL;
99 return false;
100 }
Ramkumar Radhakrishnandebfc5a2013-12-04 15:15:42 -0800101 ctx->mLayerRotMap[mDpy]->add(layer, mRot);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700102 info.format = (mRot)->getDstFormat();
103 updateSource(orient, info, sourceCrop);
104 rotFlags |= ovutils::ROT_PREROTATED;
105 }
106 return true;
107}
108
Saurabh Shah88e4d272013-09-03 13:31:29 -0700109bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800110 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500111 if(!ctx->mMDP.hasOverlay) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800112 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800113 __FUNCTION__);
114 return false;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500115 }
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800116 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800117 return mModeOn;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500118}
119
120// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700121bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800122 hwc_rect_t fbUpdatingRect, int fbZorder) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500123 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500124 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500125 if (LIKELY(ctx->mOverlay)) {
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800126 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
127 // ext only layer present..
128 if(extOnlyLayerIndex != -1) {
129 layer = &list->hwLayers[extOnlyLayerIndex];
130 layer->compositionType = HWC_OVERLAY;
131 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500132 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shah220a30c2013-10-29 16:12:12 -0700133
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700134 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
135 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
136 mTileEnabled));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500137
Saurabh Shahd4e65852013-06-17 11:33:53 -0700138 //Request a pipe
139 ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY;
140 if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) {
141 //For 8x26 external always use DMA pipe
142 type = ovutils::OV_MDP_PIPE_DMA;
143 }
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700144 ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500145 if(dest == ovutils::OV_INVALID) { //None available
Saurabh Shahaa236822013-04-24 18:07:26 -0700146 ALOGE("%s: No pipes available to configure fb for dpy %d",
147 __FUNCTION__, mDpy);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500148 return false;
149 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800150 mDest = dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500151
Ramkumar Radhakrishnan1829d282013-07-23 14:54:36 -0700152 if((mDpy && ctx->deviceOrientation) &&
153 ctx->listStats[mDpy].isDisplayAnimating) {
154 fbZorder = 0;
155 }
156
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800157 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700158 ovutils::eIsFg isFg = ovutils::IS_FG_OFF;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800159 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500160
Saurabh Shah62e1d732013-09-17 10:44:05 -0700161 hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf);
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800162 hwc_rect_t displayFrame = layer->displayFrame;
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800163
164 // No FB update optimization on (1) Custom FB resolution,
165 // (2) External Mirror mode, (3) External orientation
166 if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode
167 && !ctx->mExtOrientation) {
168 sourceCrop = fbUpdatingRect;
169 displayFrame = fbUpdatingRect;
170 }
171
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700172 int transform = layer->transform;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700173 int rotFlags = ovutils::ROT_FLAGS_NONE;
174
175 ovutils::eTransform orient =
176 static_cast<ovutils::eTransform>(transform);
Arun Kumar K.Rfb5bfa62013-07-25 03:10:51 -0700177 // use ext orientation if any
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700178 int extOrient = getExtOrientation(ctx);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700179
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700180 // Do not use getNonWormholeRegion() function to calculate the
181 // sourceCrop during animation on external display and
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700182 // Dont do wormhole calculation when extorientation is set on External
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700183 // Dont do wormhole calculation when extDownscale is enabled on External
Ramkumar Radhakrishnan59a11072013-04-15 16:14:49 -0700184 if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) {
185 sourceCrop = layer->displayFrame;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700186 } else if((!mDpy ||
Dileep Kumar Reddibf2678b2014-01-29 15:33:32 +0530187 (mDpy && !extOrient
188 && !ctx->dpyAttr[mDpy].mDownScaleMode))
189 && (extOnlyLayerIndex == -1)) {
190 if(!qdutils::MDPVersion::getInstance().is8x26() &&
191 !ctx->dpyAttr[mDpy].customFBSize) {
Saurabh Shahd4e65852013-06-17 11:33:53 -0700192 getNonWormholeRegion(list, sourceCrop);
193 displayFrame = sourceCrop;
194 }
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800195 }
Saurabh Shah220a30c2013-10-29 16:12:12 -0700196 calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame,
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700197 transform, orient);
Arun Kumar K.R8e7a62f2013-12-06 18:55:41 -0800198 //Store the displayFrame, will be used in getDisplayViewFrame
199 ctx->dpyAttr[mDpy].mDstRect = displayFrame;
Ramkumar Radhakrishnan9d52f432013-05-14 14:46:59 -0700200 setMdpFlags(layer, mdpFlags, 0, transform);
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700201 // For External use rotator if there is a rotation value set
Prabhanjan Kanduladb202b72013-10-30 17:29:46 +0530202 ret = preRotateExtDisplay(ctx, layer, info,
203 sourceCrop, mdpFlags, rotFlags);
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700204 if(!ret) {
205 ALOGE("%s: preRotate for external Failed!", __FUNCTION__);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800206 ctx->mOverlay->clear(mDpy);
207 ctx->mLayerRotMap[mDpy]->clear();
Ramkumar Radhakrishnan66f856c2013-08-21 16:09:47 -0700208 return false;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700209 }
210 //For the mdp, since either we are pre-rotating or MDP does flips
211 orient = ovutils::OVERLAY_TRANSFORM_0;
212 transform = 0;
213 ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg,
Naseer Ahmed522ce662013-03-18 20:14:05 -0400214 static_cast<ovutils::eRotFlags>(rotFlags),
215 ovutils::DEFAULT_PLANE_ALPHA,
216 (ovutils::eBlending)
217 getBlending(layer->blending));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500218 ret = true;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700219 if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame,
220 NULL, mDest) < 0) {
Saurabh Shahe2474082013-05-15 16:32:13 -0700221 ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy);
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800222 ctx->mLayerRotMap[mDpy]->clear();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500223 ret = false;
224 }
225 }
226 return ret;
227}
228
Saurabh Shah88e4d272013-09-03 13:31:29 -0700229bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500230{
Saurabh Shahcf053c62012-12-13 12:32:55 -0800231 if(!mModeOn) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500232 return true;
233 }
234 bool ret = true;
235 overlay::Overlay& ov = *(ctx->mOverlay);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800236 ovutils::eDest dest = mDest;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700237 int fd = hnd->fd;
238 uint32_t offset = hnd->offset;
239 if(mRot) {
240 if(!mRot->queueBuffer(fd, offset))
241 return false;
242 fd = mRot->getDstMemId();
243 offset = mRot->getDstOffset();
244 }
245 if (!ov.queueBuffer(fd, offset, dest)) {
Amara Venkata Mastan Manoj Kumardc01a532013-01-30 18:34:56 -0800246 ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500247 ret = false;
248 }
249 return ret;
250}
251
Saurabh Shahcf053c62012-12-13 12:32:55 -0800252//================= High res====================================
Saurabh Shah220a30c2013-10-29 16:12:12 -0700253FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy):
254 IFBUpdate(ctx, dpy) {}
Saurabh Shahcf053c62012-12-13 12:32:55 -0800255
Saurabh Shah220a30c2013-10-29 16:12:12 -0700256void FBUpdateSplit::reset() {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800257 IFBUpdate::reset();
258 mDestLeft = ovutils::OV_INVALID;
259 mDestRight = ovutils::OV_INVALID;
Arun Kumar K.Rffef7482013-04-10 14:17:22 -0700260 mRot = NULL;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800261}
262
Saurabh Shah88e4d272013-09-03 13:31:29 -0700263bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800264 hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800265 if(!ctx->mMDP.hasOverlay) {
266 ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays",
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800267 __FUNCTION__);
268 return false;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800269 }
270 ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn);
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800271 mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder);
Saurabh Shahcf053c62012-12-13 12:32:55 -0800272 return mModeOn;
273}
274
275// Configure
Saurabh Shah88e4d272013-09-03 13:31:29 -0700276bool FBUpdateSplit::configure(hwc_context_t *ctx,
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800277 hwc_display_contents_1 *list, hwc_rect_t fbUpdatingRect, int fbZorder) {
Saurabh Shahcf053c62012-12-13 12:32:55 -0800278 bool ret = false;
Naseer Ahmed64b81212013-02-14 10:29:47 -0500279 hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1];
Saurabh Shahcf053c62012-12-13 12:32:55 -0800280 if (LIKELY(ctx->mOverlay)) {
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800281 /* External only layer present */
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800282 int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex;
Arun Kumar K.Ra2978452013-02-07 01:34:24 -0800283 if(extOnlyLayerIndex != -1) {
284 layer = &list->hwLayers[extOnlyLayerIndex];
285 layer->compositionType = HWC_OVERLAY;
286 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800287 ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight,
288 ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888,
289 mTileEnabled));
290
Saurabh Shahcf053c62012-12-13 12:32:55 -0800291 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800292 ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT;
Jeykumar Sankaran85977e32013-02-25 17:06:08 -0800293 ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800294 ovutils::eTransform orient =
295 static_cast<ovutils::eTransform>(layer->transform);
296 const int hw_w = ctx->dpyAttr[mDpy].xres;
297 const int hw_h = ctx->dpyAttr[mDpy].yres;
298 const int lSplit = getLeftSplit(ctx, mDpy);
299 mDestLeft = ovutils::OV_INVALID;
300 mDestRight = ovutils::OV_INVALID;
Saurabh Shahcf053c62012-12-13 12:32:55 -0800301
Jeykumar Sankaranc2d78d82014-02-14 14:55:29 -0800302 hwc_rect_t sourceCrop = fbUpdatingRect;
303 hwc_rect_t displayFrame = fbUpdatingRect;
Saurabh Shah67a38c32013-06-10 16:23:15 -0700304
Saurabh Shahcf053c62012-12-13 12:32:55 -0800305 ret = true;
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800306 /* Configure left pipe */
307 if(displayFrame.left < lSplit) {
308 ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
309 Overlay::MIXER_LEFT);
310 if(destL == ovutils::OV_INVALID) { //None available
311 ALOGE("%s: No pipes available to configure fb for dpy %d's left"
312 " mixer", __FUNCTION__, mDpy);
313 return false;
314 }
315
316 mDestLeft = destL;
317
318 //XXX: FB layer plane alpha is currently sent as zero from
319 //surfaceflinger
320 ovutils::PipeArgs pargL(mdpFlags,
321 info,
322 zOrder,
323 ovutils::IS_FG_OFF,
324 ovutils::ROT_FLAGS_NONE,
325 ovutils::DEFAULT_PLANE_ALPHA,
326 (ovutils::eBlending)
327 getBlending(layer->blending));
328 hwc_rect_t cropL = sourceCrop;
329 hwc_rect_t dstL = displayFrame;
330 hwc_rect_t scissorL = {0, 0, lSplit, hw_h };
331 qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0);
332
333 if (configMdp(ctx->mOverlay, pargL, orient, cropL,
334 dstL, NULL, destL)< 0) {
335 ALOGE("%s: configMdp fails for left FB", __FUNCTION__);
336 ret = false;
337 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800338 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800339
340 /* Configure right pipe */
341 if(displayFrame.right > lSplit) {
342 ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy,
343 Overlay::MIXER_RIGHT);
344 if(destR == ovutils::OV_INVALID) { //None available
345 ALOGE("%s: No pipes available to configure fb for dpy %d's"
346 " right mixer", __FUNCTION__, mDpy);
347 return false;
348 }
349
350 mDestRight = destR;
351 ovutils::eMdpFlags mdpFlagsR = mdpFlags;
352 ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER);
353
354 //XXX: FB layer plane alpha is currently sent as zero from
355 //surfaceflinger
356 ovutils::PipeArgs pargR(mdpFlagsR,
357 info,
358 zOrder,
359 ovutils::IS_FG_OFF,
360 ovutils::ROT_FLAGS_NONE,
361 ovutils::DEFAULT_PLANE_ALPHA,
362 (ovutils::eBlending)
363 getBlending(layer->blending));
364
365 hwc_rect_t cropR = sourceCrop;
366 hwc_rect_t dstR = displayFrame;
367 hwc_rect_t scissorR = {lSplit, 0, hw_w, hw_h };
368 qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0);
369
370 dstR.left -= lSplit;
371 dstR.right -= lSplit;
372
373 if (configMdp(ctx->mOverlay, pargR, orient, cropR,
374 dstR, NULL, destR) < 0) {
375 ALOGE("%s: configMdp fails for right FB", __FUNCTION__);
376 ret = false;
377 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800378 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800379
Saurabh Shahda5b3ce2013-11-26 10:48:06 -0800380 if(ret == false) {
381 ctx->mLayerRotMap[mDpy]->clear();
382 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800383 }
384 return ret;
385}
386
Saurabh Shah88e4d272013-09-03 13:31:29 -0700387bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd)
Saurabh Shahcf053c62012-12-13 12:32:55 -0800388{
389 if(!mModeOn) {
390 return true;
391 }
392 bool ret = true;
393 overlay::Overlay& ov = *(ctx->mOverlay);
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800394 if(mDestLeft != ovutils::OV_INVALID) {
395 if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestLeft)) {
396 ALOGE("%s: queue failed for left of dpy = %d",
397 __FUNCTION__, mDpy);
398 ret = false;
399 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800400 }
Jeykumar Sankaranc28eb0b2014-02-27 14:42:35 -0800401 if(mDestRight != ovutils::OV_INVALID) {
402 if (!ov.queueBuffer(hnd->fd, hnd->offset, mDestRight)) {
403 ALOGE("%s: queue failed for right of dpy = %d",
404 __FUNCTION__, mDpy);
405 ret = false;
406 }
Saurabh Shahcf053c62012-12-13 12:32:55 -0800407 }
408 return ret;
409}
410
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500411//---------------------------------------------------------------------
412}; //namespace qhwc