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