Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 3 | * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 4 | * |
| 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 Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 21 | #define DEBUG_FBUPDATE 0 |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 22 | #include <cutils/properties.h> |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 23 | #include <gralloc_priv.h> |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 24 | #include <overlay.h> |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 25 | #include <overlayRotator.h> |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 26 | #include "hwc_fbupdate.h" |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 27 | #include "mdp_version.h" |
| 28 | |
| 29 | using namespace qdutils; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 30 | using namespace overlay; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 31 | using overlay::Rotator; |
Amara Venkata Mastan Manoj Kumar | 376d8a8 | 2013-03-13 19:18:47 -0700 | [diff] [blame] | 32 | using namespace overlay::utils; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 33 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 34 | namespace qhwc { |
| 35 | |
| 36 | namespace ovutils = overlay::utils; |
| 37 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 38 | IFBUpdate* IFBUpdate::getObject(hwc_context_t *ctx, const int& dpy) { |
Saurabh Shah | 60e8bde | 2014-04-30 14:46:03 -0700 | [diff] [blame] | 39 | if(qdutils::MDPVersion::getInstance().isSrcSplit()) { |
| 40 | return new FBSrcSplit(ctx, dpy); |
| 41 | } else if(isDisplaySplit(ctx, dpy)) { |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 42 | return new FBUpdateSplit(ctx, dpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 43 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 44 | return new FBUpdateNonSplit(ctx, dpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 45 | } |
| 46 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 47 | IFBUpdate::IFBUpdate(hwc_context_t *ctx, const int& dpy) : mDpy(dpy) { |
Saurabh Shah | 8f0ea6f | 2014-05-19 16:48:53 -0700 | [diff] [blame] | 48 | unsigned int size = 0; |
Dileep Kumar Reddi | e351d84 | 2014-03-25 10:39:21 +0530 | [diff] [blame] | 49 | uint32_t xres = ctx->dpyAttr[mDpy].xres; |
| 50 | uint32_t yres = ctx->dpyAttr[mDpy].yres; |
| 51 | if (ctx->dpyAttr[dpy].customFBSize) { |
| 52 | //GPU will render and compose at new resolution |
| 53 | //So need to have FB at new resolution |
| 54 | xres = ctx->dpyAttr[mDpy].xres_new; |
| 55 | yres = ctx->dpyAttr[mDpy].yres_new; |
| 56 | } |
| 57 | getBufferAttributes((int)xres, (int)yres, |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 58 | HAL_PIXEL_FORMAT_RGBA_8888, |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 59 | 0, |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 60 | mAlignedFBWidth, |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 61 | mAlignedFBHeight, |
| 62 | mTileEnabled, size); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void IFBUpdate::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 66 | mModeOn = false; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 67 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 68 | } |
| 69 | |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 70 | bool IFBUpdate::prepareAndValidate(hwc_context_t *ctx, |
| 71 | hwc_display_contents_1 *list, int fbZorder) { |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 72 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Ramkumar Radhakrishnan | 3686b7e | 2014-03-17 17:30:15 -0700 | [diff] [blame] | 73 | mModeOn = prepare(ctx, list, layer->displayFrame, fbZorder) && |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 74 | ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd); |
Ramkumar Radhakrishnan | 3686b7e | 2014-03-17 17:30:15 -0700 | [diff] [blame] | 75 | return mModeOn; |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 76 | } |
| 77 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 78 | //================= Low res==================================== |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 79 | FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy): |
| 80 | IFBUpdate(ctx, dpy) {} |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 81 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 82 | void FBUpdateNonSplit::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 83 | IFBUpdate::reset(); |
| 84 | mDest = ovutils::OV_INVALID; |
| 85 | } |
| 86 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 87 | bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx, |
Prabhanjan Kandula | db202b7 | 2013-10-30 17:29:46 +0530 | [diff] [blame] | 88 | hwc_layer_1_t *layer, |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 89 | ovutils::Whf &info, |
| 90 | hwc_rect_t& sourceCrop, |
| 91 | ovutils::eMdpFlags& mdpFlags, |
| 92 | int& rotFlags) |
| 93 | { |
| 94 | int extOrient = getExtOrientation(ctx); |
| 95 | ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient); |
| 96 | if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) { |
| 97 | mRot = ctx->mRotMgr->getNext(); |
| 98 | if(mRot == NULL) return false; |
Saurabh Shah | 39240c9 | 2014-03-31 10:31:42 -0700 | [diff] [blame] | 99 | ctx->mLayerRotMap[mDpy]->add(layer, mRot); |
Ramkumar Radhakrishnan | debfc5a | 2013-12-04 15:15:42 -0800 | [diff] [blame] | 100 | // Composed FB content will have black bars, if the viewFrame of the |
| 101 | // external is different from {0, 0, fbWidth, fbHeight}, so intersect |
| 102 | // viewFrame with sourceCrop to avoid those black bars |
| 103 | sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 104 | //Configure rotator for pre-rotation |
| 105 | if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) { |
| 106 | ALOGE("%s: configRotator Failed!", __FUNCTION__); |
| 107 | mRot = NULL; |
| 108 | return false; |
| 109 | } |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 110 | updateSource(orient, info, sourceCrop, mRot); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 111 | rotFlags |= ovutils::ROT_PREROTATED; |
| 112 | } |
| 113 | return true; |
| 114 | } |
| 115 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 116 | bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 117 | hwc_rect_t fbUpdatingRect, int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 118 | if(!ctx->mMDP.hasOverlay) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 119 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 120 | __FUNCTION__); |
| 121 | return false; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 122 | } |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 123 | mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 124 | return mModeOn; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | // Configure |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 128 | bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 129 | hwc_rect_t fbUpdatingRect, int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 130 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 131 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 132 | if (LIKELY(ctx->mOverlay)) { |
| 133 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 134 | |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 135 | int flags = mTileEnabled ? |
| 136 | private_handle_t::PRIV_FLAGS_TILE_RENDERED : 0; |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 137 | ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight, |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 138 | ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888, flags)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 139 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 140 | Overlay::PipeSpecs pipeSpecs; |
| 141 | pipeSpecs.formatClass = Overlay::FORMAT_RGB; |
| 142 | pipeSpecs.needsScaling = qhwc::needsScaling(layer); |
| 143 | pipeSpecs.dpy = mDpy; |
| 144 | pipeSpecs.mixer = Overlay::MIXER_DEFAULT; |
| 145 | pipeSpecs.fb = true; |
| 146 | |
| 147 | ovutils::eDest dest = ov.getPipe(pipeSpecs); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 148 | if(dest == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 149 | ALOGE("%s: No pipes available to configure fb for dpy %d", |
| 150 | __FUNCTION__, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 151 | return false; |
| 152 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 153 | mDest = dest; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 154 | |
Ramkumar Radhakrishnan | 1829d28 | 2013-07-23 14:54:36 -0700 | [diff] [blame] | 155 | if((mDpy && ctx->deviceOrientation) && |
| 156 | ctx->listStats[mDpy].isDisplayAnimating) { |
| 157 | fbZorder = 0; |
| 158 | } |
| 159 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 160 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Justin Philip | d616660 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 161 | ovutils::setMdpFlags(mdpFlags, |
| 162 | ovutils::OV_MDP_SMP_FORCE_ALLOC); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 163 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 164 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 165 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 166 | hwc_rect_t displayFrame = layer->displayFrame; |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 167 | |
| 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.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 176 | int transform = layer->transform; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 177 | int rotFlags = ovutils::ROT_FLAGS_NONE; |
| 178 | |
| 179 | ovutils::eTransform orient = |
| 180 | static_cast<ovutils::eTransform>(transform); |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 181 | // use ext orientation if any |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 182 | int extOrient = getExtOrientation(ctx); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 183 | |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 184 | // Do not use getNonWormholeRegion() function to calculate the |
| 185 | // sourceCrop during animation on external display and |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 186 | // Dont do wormhole calculation when extorientation is set on External |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 187 | // Dont do wormhole calculation when scaling mode is set on External |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 188 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 189 | sourceCrop = layer->displayFrame; |
Ramkumar Radhakrishnan | 3b0d972 | 2014-08-06 13:08:40 -0700 | [diff] [blame] | 190 | } else if((mDpy && !extOrient |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 191 | && !ctx->dpyAttr[mDpy].mMDPScalingMode)) { |
Raj Kamal | 068f457 | 2014-04-14 16:14:06 +0530 | [diff] [blame] | 192 | if(ctx->mOverlay->isUIScalingOnExternalSupported() && |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 193 | !ctx->dpyAttr[mDpy].customFBSize) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 194 | getNonWormholeRegion(list, sourceCrop); |
| 195 | displayFrame = sourceCrop; |
| 196 | } |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 197 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 198 | calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame, |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 199 | transform, orient); |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 200 | //Store the displayFrame, will be used in getDisplayViewFrame |
| 201 | ctx->dpyAttr[mDpy].mDstRect = displayFrame; |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 202 | setMdpFlags(ctx, layer, mdpFlags, 0, transform); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 203 | // For External use rotator if there is a rotation value set |
Prabhanjan Kandula | db202b7 | 2013-10-30 17:29:46 +0530 | [diff] [blame] | 204 | ret = preRotateExtDisplay(ctx, layer, info, |
| 205 | sourceCrop, mdpFlags, rotFlags); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 206 | if(!ret) { |
| 207 | ALOGE("%s: preRotate for external Failed!", __FUNCTION__); |
| 208 | return false; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 209 | } |
| 210 | //For the mdp, since either we are pre-rotating or MDP does flips |
| 211 | orient = ovutils::OVERLAY_TRANSFORM_0; |
| 212 | transform = 0; |
Saurabh Shah | 2c8ad05 | 2014-08-15 13:27:46 -0700 | [diff] [blame] | 213 | ovutils::PipeArgs parg(mdpFlags, info, zOrder, |
Naseer Ahmed | 522ce66 | 2013-03-18 20:14:05 -0400 | [diff] [blame] | 214 | static_cast<ovutils::eRotFlags>(rotFlags), |
| 215 | ovutils::DEFAULT_PLANE_ALPHA, |
| 216 | (ovutils::eBlending) |
| 217 | getBlending(layer->blending)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 218 | ret = true; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 219 | if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame, |
| 220 | NULL, mDest) < 0) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 221 | ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 222 | ret = false; |
| 223 | } |
| 224 | } |
| 225 | return ret; |
| 226 | } |
| 227 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 228 | bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 229 | { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 230 | if(!mModeOn) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 231 | return true; |
| 232 | } |
| 233 | bool ret = true; |
| 234 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 235 | ovutils::eDest dest = mDest; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 236 | int fd = hnd->fd; |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 237 | uint32_t offset = (uint32_t)hnd->offset; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 238 | if(mRot) { |
| 239 | if(!mRot->queueBuffer(fd, offset)) |
| 240 | return false; |
| 241 | fd = mRot->getDstMemId(); |
| 242 | offset = mRot->getDstOffset(); |
| 243 | } |
| 244 | if (!ov.queueBuffer(fd, offset, dest)) { |
Amara Venkata Mastan Manoj Kumar | dc01a53 | 2013-01-30 18:34:56 -0800 | [diff] [blame] | 245 | ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 246 | ret = false; |
| 247 | } |
| 248 | return ret; |
| 249 | } |
| 250 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 251 | //================= High res==================================== |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 252 | FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy): |
| 253 | IFBUpdate(ctx, dpy) {} |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 254 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 255 | void FBUpdateSplit::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 256 | IFBUpdate::reset(); |
| 257 | mDestLeft = ovutils::OV_INVALID; |
| 258 | mDestRight = ovutils::OV_INVALID; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 259 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 262 | bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 263 | hwc_rect_t fbUpdatingRect, int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 264 | if(!ctx->mMDP.hasOverlay) { |
| 265 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 266 | __FUNCTION__); |
| 267 | return false; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 268 | } |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 269 | mModeOn = configure(ctx, list, fbUpdatingRect, fbZorder); |
Raj Kamal | 4393eaa | 2014-06-06 13:45:20 +0530 | [diff] [blame] | 270 | ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 271 | return mModeOn; |
| 272 | } |
| 273 | |
| 274 | // Configure |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 275 | bool FBUpdateSplit::configure(hwc_context_t *ctx, |
Jeykumar Sankaran | c2d78d8 | 2014-02-14 14:55:29 -0800 | [diff] [blame] | 276 | hwc_display_contents_1 *list, hwc_rect_t fbUpdatingRect, int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 277 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 278 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 279 | if (LIKELY(ctx->mOverlay)) { |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 280 | int flags = mTileEnabled ? |
| 281 | private_handle_t::PRIV_FLAGS_TILE_RENDERED : 0; |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 282 | ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight, |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 283 | ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888, flags)); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 284 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 285 | overlay::Overlay& ov = *(ctx->mOverlay); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 286 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Justin Philip | d616660 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 287 | ovutils::setMdpFlags(mdpFlags, |
| 288 | ovutils::OV_MDP_SMP_FORCE_ALLOC); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 289 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 290 | ovutils::eTransform orient = |
| 291 | static_cast<ovutils::eTransform>(layer->transform); |
| 292 | const int hw_w = ctx->dpyAttr[mDpy].xres; |
| 293 | const int hw_h = ctx->dpyAttr[mDpy].yres; |
| 294 | const int lSplit = getLeftSplit(ctx, mDpy); |
| 295 | mDestLeft = ovutils::OV_INVALID; |
| 296 | mDestRight = ovutils::OV_INVALID; |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 297 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
| 298 | hwc_rect_t displayFrame = layer->displayFrame; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 299 | |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 300 | // No FB update optimization on (1) Custom FB resolution, |
| 301 | // (2) External Mirror mode, (3) External orientation |
| 302 | if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode |
| 303 | && !ctx->mExtOrientation) { |
| 304 | sourceCrop = fbUpdatingRect; |
| 305 | displayFrame = fbUpdatingRect; |
| 306 | } |
| 307 | |
| 308 | int transform = layer->transform; |
| 309 | // use ext orientation if any |
| 310 | int extOrient = getExtOrientation(ctx); |
| 311 | |
| 312 | // Do not use getNonWormholeRegion() function to calculate the |
| 313 | // sourceCrop during animation on external display and |
| 314 | // Dont do wormhole calculation when extorientation is set on External |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 315 | // Dont do wormhole calculation when scaling mode is set on External |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 316 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 317 | sourceCrop = layer->displayFrame; |
| 318 | } else if((mDpy && !extOrient |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 319 | && !ctx->dpyAttr[mDpy].mMDPScalingMode)) { |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 320 | if(!qdutils::MDPVersion::getInstance().is8x26() && |
| 321 | !ctx->dpyAttr[mDpy].customFBSize) { |
| 322 | getNonWormholeRegion(list, sourceCrop); |
| 323 | displayFrame = sourceCrop; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame, |
| 328 | transform, orient); |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 329 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 330 | ret = true; |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 331 | Overlay::PipeSpecs pipeSpecs; |
| 332 | pipeSpecs.formatClass = Overlay::FORMAT_RGB; |
| 333 | pipeSpecs.needsScaling = qhwc::needsScaling(layer); |
| 334 | pipeSpecs.dpy = mDpy; |
| 335 | pipeSpecs.fb = true; |
| 336 | |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 337 | /* Configure left pipe */ |
| 338 | if(displayFrame.left < lSplit) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 339 | pipeSpecs.mixer = Overlay::MIXER_LEFT; |
| 340 | ovutils::eDest destL = ov.getPipe(pipeSpecs); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 341 | if(destL == ovutils::OV_INVALID) { //None available |
| 342 | ALOGE("%s: No pipes available to configure fb for dpy %d's left" |
| 343 | " mixer", __FUNCTION__, mDpy); |
| 344 | return false; |
| 345 | } |
| 346 | |
| 347 | mDestLeft = destL; |
| 348 | |
| 349 | //XXX: FB layer plane alpha is currently sent as zero from |
| 350 | //surfaceflinger |
| 351 | ovutils::PipeArgs pargL(mdpFlags, |
| 352 | info, |
| 353 | zOrder, |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 354 | ovutils::ROT_FLAGS_NONE, |
| 355 | ovutils::DEFAULT_PLANE_ALPHA, |
| 356 | (ovutils::eBlending) |
| 357 | getBlending(layer->blending)); |
| 358 | hwc_rect_t cropL = sourceCrop; |
| 359 | hwc_rect_t dstL = displayFrame; |
| 360 | hwc_rect_t scissorL = {0, 0, lSplit, hw_h }; |
| 361 | qhwc::calculate_crop_rects(cropL, dstL, scissorL, 0); |
| 362 | |
| 363 | if (configMdp(ctx->mOverlay, pargL, orient, cropL, |
| 364 | dstL, NULL, destL)< 0) { |
| 365 | ALOGE("%s: configMdp fails for left FB", __FUNCTION__); |
| 366 | ret = false; |
| 367 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 368 | } |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 369 | |
| 370 | /* Configure right pipe */ |
| 371 | if(displayFrame.right > lSplit) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 372 | pipeSpecs.mixer = Overlay::MIXER_RIGHT; |
| 373 | ovutils::eDest destR = ov.getPipe(pipeSpecs); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 374 | if(destR == ovutils::OV_INVALID) { //None available |
| 375 | ALOGE("%s: No pipes available to configure fb for dpy %d's" |
| 376 | " right mixer", __FUNCTION__, mDpy); |
| 377 | return false; |
| 378 | } |
| 379 | |
| 380 | mDestRight = destR; |
| 381 | ovutils::eMdpFlags mdpFlagsR = mdpFlags; |
| 382 | ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER); |
| 383 | |
| 384 | //XXX: FB layer plane alpha is currently sent as zero from |
| 385 | //surfaceflinger |
| 386 | ovutils::PipeArgs pargR(mdpFlagsR, |
| 387 | info, |
| 388 | zOrder, |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 389 | ovutils::ROT_FLAGS_NONE, |
| 390 | ovutils::DEFAULT_PLANE_ALPHA, |
| 391 | (ovutils::eBlending) |
| 392 | getBlending(layer->blending)); |
| 393 | |
| 394 | hwc_rect_t cropR = sourceCrop; |
| 395 | hwc_rect_t dstR = displayFrame; |
| 396 | hwc_rect_t scissorR = {lSplit, 0, hw_w, hw_h }; |
| 397 | qhwc::calculate_crop_rects(cropR, dstR, scissorR, 0); |
| 398 | |
| 399 | dstR.left -= lSplit; |
| 400 | dstR.right -= lSplit; |
| 401 | |
| 402 | if (configMdp(ctx->mOverlay, pargR, orient, cropR, |
| 403 | dstR, NULL, destR) < 0) { |
| 404 | ALOGE("%s: configMdp fails for right FB", __FUNCTION__); |
| 405 | ret = false; |
| 406 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | return ret; |
| 410 | } |
| 411 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 412 | bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 413 | { |
| 414 | if(!mModeOn) { |
| 415 | return true; |
| 416 | } |
| 417 | bool ret = true; |
| 418 | overlay::Overlay& ov = *(ctx->mOverlay); |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 419 | if(mDestLeft != ovutils::OV_INVALID) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 420 | if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestLeft)) { |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 421 | ALOGE("%s: queue failed for left of dpy = %d", |
| 422 | __FUNCTION__, mDpy); |
| 423 | ret = false; |
| 424 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 425 | } |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 426 | if(mDestRight != ovutils::OV_INVALID) { |
Praveena Pachipulusu | d9443c7 | 2014-02-17 10:42:28 +0530 | [diff] [blame] | 427 | if (!ov.queueBuffer(hnd->fd, (uint32_t)hnd->offset, mDestRight)) { |
Jeykumar Sankaran | c28eb0b | 2014-02-27 14:42:35 -0800 | [diff] [blame] | 428 | ALOGE("%s: queue failed for right of dpy = %d", |
| 429 | __FUNCTION__, mDpy); |
| 430 | ret = false; |
| 431 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 432 | } |
| 433 | return ret; |
| 434 | } |
| 435 | |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 436 | //=================FBSrcSplit==================================== |
| 437 | FBSrcSplit::FBSrcSplit(hwc_context_t *ctx, const int& dpy): |
| 438 | FBUpdateSplit(ctx, dpy) {} |
| 439 | |
| 440 | bool FBSrcSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
| 441 | hwc_rect_t fbUpdatingRect, int fbZorder) { |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 442 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 443 | overlay::Overlay& ov = *(ctx->mOverlay); |
| 444 | |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 445 | int flags = mTileEnabled ? private_handle_t::PRIV_FLAGS_TILE_RENDERED : 0; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 446 | ovutils::Whf info(mAlignedFBWidth, |
| 447 | mAlignedFBHeight, |
Sushil Chauhan | 65e2630 | 2015-01-14 10:48:57 -0800 | [diff] [blame] | 448 | ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888, flags)); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 449 | |
| 450 | ovutils::eMdpFlags mdpFlags = OV_MDP_BLEND_FG_PREMULT; |
Justin Philip | d616660 | 2014-08-12 13:42:21 +0530 | [diff] [blame] | 451 | ovutils::setMdpFlags(mdpFlags, |
| 452 | ovutils::OV_MDP_SMP_FORCE_ALLOC); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 453 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
| 454 | |
| 455 | ovutils::PipeArgs parg(mdpFlags, |
| 456 | info, |
| 457 | zOrder, |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 458 | ovutils::ROT_FLAGS_NONE, |
| 459 | ovutils::DEFAULT_PLANE_ALPHA, |
| 460 | (ovutils::eBlending) |
| 461 | getBlending(layer->blending)); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 462 | |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 463 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
| 464 | hwc_rect_t displayFrame = layer->displayFrame; |
| 465 | |
| 466 | // No FB update optimization on (1) Custom FB resolution, |
| 467 | // (2) External Mirror mode, (3) External orientation |
| 468 | if(!ctx->dpyAttr[mDpy].customFBSize && !ctx->mBufferMirrorMode |
| 469 | && !ctx->mExtOrientation) { |
| 470 | sourceCrop = fbUpdatingRect; |
| 471 | displayFrame = fbUpdatingRect; |
| 472 | } |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 473 | int transform = layer->transform; |
| 474 | ovutils::eTransform orient = |
| 475 | static_cast<ovutils::eTransform>(transform); |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 476 | |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 477 | // use ext orientation if any |
| 478 | int extOrient = getExtOrientation(ctx); |
| 479 | |
| 480 | // Do not use getNonWormholeRegion() function to calculate the |
| 481 | // sourceCrop during animation on external display and |
| 482 | // Dont do wormhole calculation when extorientation is set on External |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 483 | // Dont do wormhole calculation when scaling mode is set on External |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 484 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 485 | sourceCrop = layer->displayFrame; |
| 486 | } else if((mDpy && !extOrient |
Tatenda Chipeperekwa | cb2a243 | 2014-08-06 17:45:58 -0700 | [diff] [blame] | 487 | && !ctx->dpyAttr[mDpy].mMDPScalingMode)) { |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 488 | if(!qdutils::MDPVersion::getInstance().is8x26() && |
| 489 | !ctx->dpyAttr[mDpy].customFBSize) { |
| 490 | getNonWormholeRegion(list, sourceCrop); |
| 491 | displayFrame = sourceCrop; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame, |
| 496 | transform, orient); |
| 497 | hwc_rect_t cropL = sourceCrop; |
| 498 | hwc_rect_t cropR = sourceCrop; |
| 499 | hwc_rect_t dstL = displayFrame; |
| 500 | hwc_rect_t dstR = displayFrame; |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 501 | |
| 502 | //Request left pipe (or 1 by default) |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 503 | Overlay::PipeSpecs pipeSpecs; |
| 504 | pipeSpecs.formatClass = Overlay::FORMAT_RGB; |
| 505 | pipeSpecs.needsScaling = qhwc::needsScaling(layer); |
| 506 | pipeSpecs.dpy = mDpy; |
| 507 | pipeSpecs.mixer = Overlay::MIXER_DEFAULT; |
| 508 | pipeSpecs.fb = true; |
| 509 | ovutils::eDest destL = ov.getPipe(pipeSpecs); |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 510 | if(destL == ovutils::OV_INVALID) { |
| 511 | ALOGE("%s: No pipes available to configure fb for dpy %d's left" |
| 512 | " mixer", __FUNCTION__, mDpy); |
| 513 | return false; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 514 | } |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 515 | |
| 516 | ovutils::eDest destR = ovutils::OV_INVALID; |
| 517 | |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 518 | /* Use 2 pipes IF |
Prabhanjan Kandula | 5bae9f5 | 2014-05-15 16:48:18 +0530 | [diff] [blame] | 519 | a) FB's width is > Mixer width or |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 520 | b) On primary, driver has indicated with caps to split always. This is |
| 521 | based on an empirically derived value of panel height. |
| 522 | */ |
| 523 | |
Saurabh Shah | 189f23d | 2014-09-26 17:21:00 -0700 | [diff] [blame] | 524 | const bool primarySplitAlways = (mDpy == HWC_DISPLAY_PRIMARY) and |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 525 | qdutils::MDPVersion::getInstance().isSrcSplitAlways(); |
Saurabh Shah | 189f23d | 2014-09-26 17:21:00 -0700 | [diff] [blame] | 526 | const uint32_t lSplit = getLeftSplit(ctx, mDpy); |
| 527 | const uint32_t cropWidth = sourceCrop.right - sourceCrop.left; |
Saurabh Shah | 514759d | 2014-11-11 18:02:24 -0800 | [diff] [blame] | 528 | const uint32_t cropHeight = sourceCrop.bottom - sourceCrop.top; |
| 529 | const uint32_t dstWidth = displayFrame.right - displayFrame.left; |
| 530 | const uint32_t dstHeight = displayFrame.bottom - displayFrame.top; |
| 531 | const uint32_t layerClock = getLayerClock(dstWidth, dstHeight, cropHeight); |
| 532 | const uint32_t mixerClock = lSplit; |
Saurabh Shah | ea7a01d | 2014-05-22 17:45:36 -0700 | [diff] [blame] | 533 | |
Jeykumar Sankaran | 3930580 | 2014-12-12 17:55:57 -0800 | [diff] [blame] | 534 | if((cropWidth > qdutils::MDPVersion::getInstance().getMaxPipeWidth()) or |
Saurabh Shah | 514759d | 2014-11-11 18:02:24 -0800 | [diff] [blame] | 535 | (primarySplitAlways and |
| 536 | (cropWidth > lSplit or layerClock > mixerClock))) { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 537 | destR = ov.getPipe(pipeSpecs); |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 538 | if(destR == ovutils::OV_INVALID) { |
| 539 | ALOGE("%s: No pipes available to configure fb for dpy %d's right" |
| 540 | " mixer", __FUNCTION__, mDpy); |
| 541 | return false; |
| 542 | } |
| 543 | |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 544 | if(ctx->mOverlay->needsPrioritySwap(destL, destR)) { |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 545 | qhwc::swap(destL, destR); |
| 546 | } |
| 547 | |
| 548 | //Split crop equally when using 2 pipes |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 549 | cropL.right = (sourceCrop.right + sourceCrop.left) / 2; |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 550 | cropR.left = cropL.right; |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 551 | dstL.right = (displayFrame.right + displayFrame.left) / 2; |
| 552 | dstR.left = dstL.right; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 553 | } |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 554 | |
| 555 | mDestLeft = destL; |
| 556 | mDestRight = destR; |
| 557 | |
| 558 | if(destL != OV_INVALID) { |
| 559 | if(configMdp(ctx->mOverlay, parg, orient, |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 560 | cropL, dstL, NULL /*metadata*/, destL) < 0) { |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 561 | ALOGE("%s: commit failed for left mixer config", __FUNCTION__); |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 562 | return false; |
| 563 | } |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 564 | } |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 565 | |
| 566 | //configure right pipe |
| 567 | if(destR != OV_INVALID) { |
| 568 | if(configMdp(ctx->mOverlay, parg, orient, |
Ramkumar Radhakrishnan | e1f433a | 2014-08-06 12:10:33 -0700 | [diff] [blame] | 569 | cropR, dstR, NULL /*metadata*/, destR) < 0) { |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 570 | ALOGE("%s: commit failed for right mixer config", __FUNCTION__); |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 571 | return false; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | return true; |
Saurabh Shah | ab47c69 | 2014-02-12 18:45:57 -0800 | [diff] [blame] | 576 | } |
| 577 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 578 | //--------------------------------------------------------------------- |
| 579 | }; //namespace qhwc |