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