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