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