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 | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 42 | return new FBUpdateSplit(ctx, dpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 43 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 44 | return new FBUpdateNonSplit(ctx, dpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 45 | } |
| 46 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 47 | IFBUpdate::IFBUpdate(hwc_context_t *ctx, const int& dpy) : mDpy(dpy) { |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame^] | 48 | size_t size = 0; |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 49 | getBufferAttributes(ctx->dpyAttr[mDpy].xres, |
| 50 | ctx->dpyAttr[mDpy].yres, |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 51 | HAL_PIXEL_FORMAT_RGBA_8888, |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 52 | 0, |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 53 | mAlignedFBWidth, |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 54 | mAlignedFBHeight, |
| 55 | mTileEnabled, size); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void IFBUpdate::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 59 | mModeOn = false; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 60 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 63 | bool IFBUpdate::prepareAndValidate(hwc_context_t *ctx, |
| 64 | hwc_display_contents_1 *list, int fbZorder) { |
| 65 | return prepare(ctx, list, fbZorder) && |
| 66 | ctx->mOverlay->validateAndSet(mDpy, ctx->dpyAttr[mDpy].fd); |
| 67 | } |
| 68 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 69 | //================= Low res==================================== |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 70 | FBUpdateNonSplit::FBUpdateNonSplit(hwc_context_t *ctx, const int& dpy): |
| 71 | IFBUpdate(ctx, dpy) {} |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 72 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 73 | void FBUpdateNonSplit::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 74 | IFBUpdate::reset(); |
| 75 | mDest = ovutils::OV_INVALID; |
| 76 | } |
| 77 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 78 | bool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx, |
Prabhanjan Kandula | db202b7 | 2013-10-30 17:29:46 +0530 | [diff] [blame] | 79 | hwc_layer_1_t *layer, |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 80 | ovutils::Whf &info, |
| 81 | hwc_rect_t& sourceCrop, |
| 82 | ovutils::eMdpFlags& mdpFlags, |
| 83 | int& rotFlags) |
| 84 | { |
| 85 | int extOrient = getExtOrientation(ctx); |
| 86 | ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient); |
| 87 | if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) { |
| 88 | mRot = ctx->mRotMgr->getNext(); |
| 89 | if(mRot == NULL) return false; |
Ramkumar Radhakrishnan | debfc5a | 2013-12-04 15:15:42 -0800 | [diff] [blame] | 90 | // Composed FB content will have black bars, if the viewFrame of the |
| 91 | // external is different from {0, 0, fbWidth, fbHeight}, so intersect |
| 92 | // viewFrame with sourceCrop to avoid those black bars |
| 93 | sourceCrop = getIntersection(sourceCrop, ctx->mViewFrame[mDpy]); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 94 | //Configure rotator for pre-rotation |
| 95 | if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) { |
| 96 | ALOGE("%s: configRotator Failed!", __FUNCTION__); |
| 97 | mRot = NULL; |
| 98 | return false; |
| 99 | } |
Ramkumar Radhakrishnan | debfc5a | 2013-12-04 15:15:42 -0800 | [diff] [blame] | 100 | ctx->mLayerRotMap[mDpy]->add(layer, mRot); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 101 | info.format = (mRot)->getDstFormat(); |
| 102 | updateSource(orient, info, sourceCrop); |
| 103 | rotFlags |= ovutils::ROT_PREROTATED; |
| 104 | } |
| 105 | return true; |
| 106 | } |
| 107 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 108 | bool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 109 | int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 110 | if(!ctx->mMDP.hasOverlay) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 111 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 112 | __FUNCTION__); |
| 113 | return false; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 114 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 115 | mModeOn = configure(ctx, list, fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 116 | return mModeOn; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | // Configure |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 120 | bool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 121 | int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 122 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 123 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 124 | if (LIKELY(ctx->mOverlay)) { |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 125 | int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; |
| 126 | // ext only layer present.. |
| 127 | if(extOnlyLayerIndex != -1) { |
| 128 | layer = &list->hwLayers[extOnlyLayerIndex]; |
| 129 | layer->compositionType = HWC_OVERLAY; |
| 130 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 131 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 132 | |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 133 | ovutils::Whf info(mAlignedFBWidth, mAlignedFBHeight, |
| 134 | ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888, |
| 135 | mTileEnabled)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 136 | |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 137 | //Request a pipe |
| 138 | ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY; |
| 139 | if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) { |
| 140 | //For 8x26 external always use DMA pipe |
| 141 | type = ovutils::OV_MDP_PIPE_DMA; |
| 142 | } |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 143 | ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 144 | if(dest == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 145 | ALOGE("%s: No pipes available to configure fb for dpy %d", |
| 146 | __FUNCTION__, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 147 | return false; |
| 148 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 149 | mDest = dest; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 150 | |
Ramkumar Radhakrishnan | 1829d28 | 2013-07-23 14:54:36 -0700 | [diff] [blame] | 151 | if((mDpy && ctx->deviceOrientation) && |
| 152 | ctx->listStats[mDpy].isDisplayAnimating) { |
| 153 | fbZorder = 0; |
| 154 | } |
| 155 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 156 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 157 | ovutils::eIsFg isFg = ovutils::IS_FG_OFF; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 158 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 159 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 160 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 161 | hwc_rect_t displayFrame = layer->displayFrame; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 162 | int transform = layer->transform; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 163 | int rotFlags = ovutils::ROT_FLAGS_NONE; |
| 164 | |
| 165 | ovutils::eTransform orient = |
| 166 | static_cast<ovutils::eTransform>(transform); |
Arun Kumar K.R | fb5bfa6 | 2013-07-25 03:10:51 -0700 | [diff] [blame] | 167 | // use ext orientation if any |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 168 | int extOrient = getExtOrientation(ctx); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 169 | |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 170 | // Do not use getNonWormholeRegion() function to calculate the |
| 171 | // sourceCrop during animation on external display and |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 172 | // 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] | 173 | // Dont do wormhole calculation when extDownscale is enabled on External |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 174 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 175 | sourceCrop = layer->displayFrame; |
Amara Venkata Mastan Manoj Kumar | 376d8a8 | 2013-03-13 19:18:47 -0700 | [diff] [blame] | 176 | } else if((!mDpy || |
Dileep Kumar Reddi | bf2678b | 2014-01-29 15:33:32 +0530 | [diff] [blame] | 177 | (mDpy && !extOrient |
| 178 | && !ctx->dpyAttr[mDpy].mDownScaleMode)) |
| 179 | && (extOnlyLayerIndex == -1)) { |
| 180 | if(!qdutils::MDPVersion::getInstance().is8x26() && |
| 181 | !ctx->dpyAttr[mDpy].customFBSize) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 182 | getNonWormholeRegion(list, sourceCrop); |
| 183 | displayFrame = sourceCrop; |
| 184 | } |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 185 | } |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 186 | calcExtDisplayPosition(ctx, NULL, mDpy, sourceCrop, displayFrame, |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 187 | transform, orient); |
Arun Kumar K.R | 8e7a62f | 2013-12-06 18:55:41 -0800 | [diff] [blame] | 188 | //Store the displayFrame, will be used in getDisplayViewFrame |
| 189 | ctx->dpyAttr[mDpy].mDstRect = displayFrame; |
Ramkumar Radhakrishnan | 9d52f43 | 2013-05-14 14:46:59 -0700 | [diff] [blame] | 190 | setMdpFlags(layer, mdpFlags, 0, transform); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 191 | // For External use rotator if there is a rotation value set |
Prabhanjan Kandula | db202b7 | 2013-10-30 17:29:46 +0530 | [diff] [blame] | 192 | ret = preRotateExtDisplay(ctx, layer, info, |
| 193 | sourceCrop, mdpFlags, rotFlags); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 194 | if(!ret) { |
| 195 | ALOGE("%s: preRotate for external Failed!", __FUNCTION__); |
Saurabh Shah | da5b3ce | 2013-11-26 10:48:06 -0800 | [diff] [blame] | 196 | ctx->mOverlay->clear(mDpy); |
| 197 | ctx->mLayerRotMap[mDpy]->clear(); |
Ramkumar Radhakrishnan | 66f856c | 2013-08-21 16:09:47 -0700 | [diff] [blame] | 198 | return false; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 199 | } |
| 200 | //For the mdp, since either we are pre-rotating or MDP does flips |
| 201 | orient = ovutils::OVERLAY_TRANSFORM_0; |
| 202 | transform = 0; |
| 203 | ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg, |
Naseer Ahmed | 522ce66 | 2013-03-18 20:14:05 -0400 | [diff] [blame] | 204 | static_cast<ovutils::eRotFlags>(rotFlags), |
| 205 | ovutils::DEFAULT_PLANE_ALPHA, |
| 206 | (ovutils::eBlending) |
| 207 | getBlending(layer->blending)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 208 | ret = true; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 209 | if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame, |
| 210 | NULL, mDest) < 0) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 211 | ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy); |
Saurabh Shah | da5b3ce | 2013-11-26 10:48:06 -0800 | [diff] [blame] | 212 | ctx->mLayerRotMap[mDpy]->clear(); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 213 | ret = false; |
| 214 | } |
| 215 | } |
| 216 | return ret; |
| 217 | } |
| 218 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 219 | bool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 220 | { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 221 | if(!mModeOn) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 222 | return true; |
| 223 | } |
| 224 | bool ret = true; |
| 225 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 226 | ovutils::eDest dest = mDest; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 227 | int fd = hnd->fd; |
| 228 | uint32_t offset = hnd->offset; |
| 229 | if(mRot) { |
| 230 | if(!mRot->queueBuffer(fd, offset)) |
| 231 | return false; |
| 232 | fd = mRot->getDstMemId(); |
| 233 | offset = mRot->getDstOffset(); |
| 234 | } |
| 235 | if (!ov.queueBuffer(fd, offset, dest)) { |
Amara Venkata Mastan Manoj Kumar | dc01a53 | 2013-01-30 18:34:56 -0800 | [diff] [blame] | 236 | ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 237 | ret = false; |
| 238 | } |
| 239 | return ret; |
| 240 | } |
| 241 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 242 | //================= High res==================================== |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 243 | FBUpdateSplit::FBUpdateSplit(hwc_context_t *ctx, const int& dpy): |
| 244 | IFBUpdate(ctx, dpy) {} |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 245 | |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 246 | void FBUpdateSplit::reset() { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 247 | IFBUpdate::reset(); |
| 248 | mDestLeft = ovutils::OV_INVALID; |
| 249 | mDestRight = ovutils::OV_INVALID; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 250 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 251 | } |
| 252 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 253 | bool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 254 | int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 255 | if(!ctx->mMDP.hasOverlay) { |
| 256 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 257 | __FUNCTION__); |
| 258 | return false; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 259 | } |
| 260 | ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 261 | mModeOn = configure(ctx, list, fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 262 | return mModeOn; |
| 263 | } |
| 264 | |
| 265 | // Configure |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 266 | bool FBUpdateSplit::configure(hwc_context_t *ctx, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 267 | hwc_display_contents_1 *list, int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 268 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 269 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 270 | if (LIKELY(ctx->mOverlay)) { |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 271 | int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; |
| 272 | // ext only layer present.. |
| 273 | if(extOnlyLayerIndex != -1) { |
| 274 | layer = &list->hwLayers[extOnlyLayerIndex]; |
| 275 | layer->compositionType = HWC_OVERLAY; |
| 276 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 277 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | 220a30c | 2013-10-29 16:12:12 -0700 | [diff] [blame] | 278 | |
| 279 | ovutils::Whf info(mAlignedFBWidth, |
| 280 | mAlignedFBHeight, |
Manoj Kumar AVM | 8a22081 | 2013-10-10 11:46:06 -0700 | [diff] [blame] | 281 | ovutils::getMdpFormat(HAL_PIXEL_FORMAT_RGBA_8888, |
| 282 | mTileEnabled)); |
Saurabh Shah | c66f54d | 2013-06-12 15:45:59 -0700 | [diff] [blame] | 283 | //Request left pipe |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 284 | ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy, |
| 285 | Overlay::MIXER_LEFT); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 286 | if(destL == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 287 | ALOGE("%s: No pipes available to configure fb for dpy %d's left" |
| 288 | " mixer", __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 289 | return false; |
| 290 | } |
Saurabh Shah | c66f54d | 2013-06-12 15:45:59 -0700 | [diff] [blame] | 291 | //Request right pipe |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 292 | ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy, |
| 293 | Overlay::MIXER_RIGHT); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 294 | if(destR == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 295 | ALOGE("%s: No pipes available to configure fb for dpy %d's right" |
| 296 | " mixer", __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 297 | return false; |
| 298 | } |
| 299 | |
| 300 | mDestLeft = destL; |
| 301 | mDestRight = destR; |
| 302 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 303 | ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Sravan Kumar D.V.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 304 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 305 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 306 | |
Naseer Ahmed | 522ce66 | 2013-03-18 20:14:05 -0400 | [diff] [blame] | 307 | //XXX: FB layer plane alpha is currently sent as zero from |
| 308 | //surfaceflinger |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 309 | ovutils::PipeArgs pargL(mdpFlagsL, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 310 | info, |
| 311 | zOrder, |
| 312 | ovutils::IS_FG_OFF, |
Naseer Ahmed | 522ce66 | 2013-03-18 20:14:05 -0400 | [diff] [blame] | 313 | ovutils::ROT_FLAGS_NONE, |
| 314 | ovutils::DEFAULT_PLANE_ALPHA, |
| 315 | (ovutils::eBlending) |
| 316 | getBlending(layer->blending)); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 317 | ov.setSource(pargL, destL); |
| 318 | |
| 319 | ovutils::eMdpFlags mdpFlagsR = mdpFlagsL; |
| 320 | ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER); |
| 321 | ovutils::PipeArgs pargR(mdpFlagsR, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 322 | info, |
| 323 | zOrder, |
| 324 | ovutils::IS_FG_OFF, |
Naseer Ahmed | 522ce66 | 2013-03-18 20:14:05 -0400 | [diff] [blame] | 325 | ovutils::ROT_FLAGS_NONE, |
| 326 | ovutils::DEFAULT_PLANE_ALPHA, |
| 327 | (ovutils::eBlending) |
| 328 | getBlending(layer->blending)); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 329 | ov.setSource(pargR, destR); |
| 330 | |
Saurabh Shah | 62e1d73 | 2013-09-17 10:44:05 -0700 | [diff] [blame] | 331 | hwc_rect_t sourceCrop = integerizeSourceCrop(layer->sourceCropf); |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 332 | hwc_rect_t displayFrame = layer->displayFrame; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 333 | |
| 334 | const float xres = ctx->dpyAttr[mDpy].xres; |
Saurabh Shah | 07a8ca8 | 2013-08-06 18:45:42 -0700 | [diff] [blame] | 335 | const int lSplit = getLeftSplit(ctx, mDpy); |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 336 | const float lSplitRatio = lSplit / xres; |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 337 | const float lCropWidth = |
| 338 | (sourceCrop.right - sourceCrop.left) * lSplitRatio; |
| 339 | |
| 340 | ovutils::Dim dcropL( |
| 341 | sourceCrop.left, |
| 342 | sourceCrop.top, |
| 343 | lCropWidth, |
| 344 | sourceCrop.bottom - sourceCrop.top); |
| 345 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 346 | ovutils::Dim dcropR( |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 347 | sourceCrop.left + lCropWidth, |
| 348 | sourceCrop.top, |
| 349 | (sourceCrop.right - sourceCrop.left) - lCropWidth, |
| 350 | sourceCrop.bottom - sourceCrop.top); |
| 351 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 352 | ov.setCrop(dcropL, destL); |
| 353 | ov.setCrop(dcropR, destR); |
| 354 | |
| 355 | int transform = layer->transform; |
| 356 | ovutils::eTransform orient = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 357 | static_cast<ovutils::eTransform>(transform); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 358 | ov.setTransform(orient, destL); |
| 359 | ov.setTransform(orient, destR); |
| 360 | |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 361 | const int lWidth = (lSplit - displayFrame.left); |
| 362 | const int rWidth = (displayFrame.right - lSplit); |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 363 | const int height = displayFrame.bottom - displayFrame.top; |
| 364 | |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 365 | ovutils::Dim dposL(displayFrame.left, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 366 | displayFrame.top, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 367 | lWidth, |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 368 | height); |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 369 | ov.setPosition(dposL, destL); |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 370 | |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 371 | ovutils::Dim dposR(0, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 372 | displayFrame.top, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 373 | rWidth, |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 374 | height); |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 375 | ov.setPosition(dposR, destR); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 376 | |
| 377 | ret = true; |
| 378 | if (!ov.commit(destL)) { |
| 379 | ALOGE("%s: commit fails for left", __FUNCTION__); |
| 380 | ret = false; |
| 381 | } |
| 382 | if (!ov.commit(destR)) { |
| 383 | ALOGE("%s: commit fails for right", __FUNCTION__); |
| 384 | ret = false; |
| 385 | } |
Saurabh Shah | da5b3ce | 2013-11-26 10:48:06 -0800 | [diff] [blame] | 386 | if(ret == false) { |
| 387 | ctx->mLayerRotMap[mDpy]->clear(); |
| 388 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 389 | } |
| 390 | return ret; |
| 391 | } |
| 392 | |
Saurabh Shah | 88e4d27 | 2013-09-03 13:31:29 -0700 | [diff] [blame] | 393 | bool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 394 | { |
| 395 | if(!mModeOn) { |
| 396 | return true; |
| 397 | } |
| 398 | bool ret = true; |
| 399 | overlay::Overlay& ov = *(ctx->mOverlay); |
| 400 | ovutils::eDest destL = mDestLeft; |
| 401 | ovutils::eDest destR = mDestRight; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 402 | if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) { |
| 403 | ALOGE("%s: queue failed for left of dpy = %d", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 404 | __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 405 | ret = false; |
| 406 | } |
| 407 | if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) { |
| 408 | ALOGE("%s: queue failed for right of dpy = %d", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 409 | __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 410 | ret = false; |
| 411 | } |
| 412 | return ret; |
| 413 | } |
| 414 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 415 | //--------------------------------------------------------------------- |
| 416 | }; //namespace qhwc |