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