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