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