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> |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 24 | #include <overlayRotator.h> |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 25 | #include "hwc_fbupdate.h" |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 26 | #include "mdp_version.h" |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 27 | #include "external.h" |
Saurabh Shah | bd2d083 | 2013-04-04 14:33:08 -0700 | [diff] [blame] | 28 | |
| 29 | using namespace qdutils; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 30 | |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 31 | using overlay::Rotator; |
| 32 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 33 | namespace qhwc { |
| 34 | |
| 35 | namespace ovutils = overlay::utils; |
| 36 | |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 37 | IFBUpdate* IFBUpdate::getObject(const int& width, const int& rightSplit, |
| 38 | const int& dpy) { |
| 39 | if(width > MAX_DISPLAY_DIM || rightSplit) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 40 | return new FBUpdateHighRes(dpy); |
| 41 | } |
| 42 | return new FBUpdateLowRes(dpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 43 | } |
| 44 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 45 | inline void IFBUpdate::reset() { |
| 46 | mModeOn = false; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 47 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | //================= Low res==================================== |
| 51 | FBUpdateLowRes::FBUpdateLowRes(const int& dpy): IFBUpdate(dpy) {} |
| 52 | |
| 53 | inline void FBUpdateLowRes::reset() { |
| 54 | IFBUpdate::reset(); |
| 55 | mDest = ovutils::OV_INVALID; |
| 56 | } |
| 57 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 58 | bool FBUpdateLowRes::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
| 59 | int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 60 | if(!ctx->mMDP.hasOverlay) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 61 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 62 | __FUNCTION__); |
| 63 | return false; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 64 | } |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 65 | mModeOn = configure(ctx, list, fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 66 | return mModeOn; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | // Configure |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 70 | bool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_display_contents_1 *list, |
| 71 | int fbZorder) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 72 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 73 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 74 | if (LIKELY(ctx->mOverlay)) { |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 75 | int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; |
| 76 | // ext only layer present.. |
| 77 | if(extOnlyLayerIndex != -1) { |
| 78 | layer = &list->hwLayers[extOnlyLayerIndex]; |
| 79 | layer->compositionType = HWC_OVERLAY; |
| 80 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 81 | overlay::Overlay& ov = *(ctx->mOverlay); |
| 82 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 83 | ovutils::Whf info(hnd->width, hnd->height, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 84 | ovutils::getMdpFormat(hnd->format), hnd->size); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 85 | |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 86 | //Request a pipe |
| 87 | ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY; |
| 88 | if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) { |
| 89 | //For 8x26 external always use DMA pipe |
| 90 | type = ovutils::OV_MDP_PIPE_DMA; |
| 91 | } |
| 92 | ovutils::eDest dest = ov.nextPipe(type, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 93 | if(dest == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 94 | ALOGE("%s: No pipes available to configure fb for dpy %d", |
| 95 | __FUNCTION__, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 96 | return false; |
| 97 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 98 | mDest = dest; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 99 | |
Ramkumar Radhakrishnan | 1829d28 | 2013-07-23 14:54:36 -0700 | [diff] [blame^] | 100 | if((mDpy && ctx->deviceOrientation) && |
| 101 | ctx->listStats[mDpy].isDisplayAnimating) { |
| 102 | fbZorder = 0; |
| 103 | } |
| 104 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 105 | ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 106 | ovutils::eIsFg isFg = ovutils::IS_FG_OFF; |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 107 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 108 | |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 109 | hwc_rect_t sourceCrop = layer->sourceCrop; |
| 110 | hwc_rect_t displayFrame = layer->displayFrame; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 111 | int transform = layer->transform; |
| 112 | int fbWidth = ctx->dpyAttr[mDpy].xres; |
| 113 | int fbHeight = ctx->dpyAttr[mDpy].yres; |
| 114 | int rotFlags = ovutils::ROT_FLAGS_NONE; |
| 115 | |
| 116 | ovutils::eTransform orient = |
| 117 | static_cast<ovutils::eTransform>(transform); |
| 118 | if(mDpy && ctx->mExtOrientation) { |
| 119 | // If there is a external orientation set, use that |
| 120 | transform = ctx->mExtOrientation; |
| 121 | orient = static_cast<ovutils::eTransform >(ctx->mExtOrientation); |
| 122 | } |
| 123 | |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 124 | // Do not use getNonWormholeRegion() function to calculate the |
| 125 | // sourceCrop during animation on external display and |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 126 | // Dont do wormhole calculation when extorientation is set on External |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 127 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 128 | sourceCrop = layer->displayFrame; |
| 129 | displayFrame = sourceCrop; |
| 130 | } else if((!mDpy || (mDpy && !ctx->mExtOrientation)) |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 131 | && extOnlyLayerIndex == -1) { |
Saurabh Shah | d4e6585 | 2013-06-17 11:33:53 -0700 | [diff] [blame] | 132 | if(!qdutils::MDPVersion::getInstance().is8x26()) { |
| 133 | getNonWormholeRegion(list, sourceCrop); |
| 134 | displayFrame = sourceCrop; |
| 135 | } |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 136 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 137 | ovutils::Dim dpos(displayFrame.left, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 138 | displayFrame.top, |
| 139 | displayFrame.right - displayFrame.left, |
| 140 | displayFrame.bottom - displayFrame.top); |
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 | if(mDpy && !qdutils::MDPVersion::getInstance().is8x26()) { |
Arun Kumar K.R | 82f1d28 | 2013-05-17 15:37:31 -0700 | [diff] [blame] | 143 | // Get Aspect Ratio for external |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 144 | getAspectRatioPosition(ctx, mDpy, ctx->mExtOrientation, dpos.x, |
| 145 | dpos.y, dpos.w, dpos.h); |
Arun Kumar K.R | 82f1d28 | 2013-05-17 15:37:31 -0700 | [diff] [blame] | 146 | // Calculate the actionsafe dimensions for External(dpy = 1 or 2) |
| 147 | getActionSafePosition(ctx, mDpy, dpos.x, dpos.y, dpos.w, dpos.h); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 148 | // Convert dim to hwc_rect_t |
| 149 | displayFrame.left = dpos.x; |
| 150 | displayFrame.top = dpos.y; |
| 151 | displayFrame.right = dpos.w + displayFrame.left; |
| 152 | displayFrame.bottom = dpos.h + displayFrame.top; |
| 153 | } |
Ramkumar Radhakrishnan | 9d52f43 | 2013-05-14 14:46:59 -0700 | [diff] [blame] | 154 | setMdpFlags(layer, mdpFlags, 0, transform); |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 155 | // For External use rotator if there is a rotation value set |
| 156 | if(mDpy && (ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)) { |
| 157 | mRot = ctx->mRotMgr->getNext(); |
| 158 | if(mRot == NULL) return -1; |
| 159 | //Configure rotator for pre-rotation |
| 160 | if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) { |
| 161 | ALOGE("%s: configRotator Failed!", __FUNCTION__); |
| 162 | mRot = NULL; |
| 163 | return -1; |
| 164 | } |
| 165 | info.format = (mRot)->getDstFormat(); |
| 166 | updateSource(orient, info, sourceCrop); |
| 167 | rotFlags |= ovutils::ROT_PREROTATED; |
| 168 | } |
| 169 | //For the mdp, since either we are pre-rotating or MDP does flips |
| 170 | orient = ovutils::OVERLAY_TRANSFORM_0; |
| 171 | transform = 0; |
| 172 | ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg, |
| 173 | static_cast<ovutils::eRotFlags>(rotFlags)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 174 | ret = true; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 175 | if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame, |
| 176 | NULL, mDest) < 0) { |
Saurabh Shah | e247408 | 2013-05-15 16:32:13 -0700 | [diff] [blame] | 177 | ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 178 | ret = false; |
| 179 | } |
| 180 | } |
| 181 | return ret; |
| 182 | } |
| 183 | |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 184 | bool FBUpdateLowRes::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 185 | { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 186 | if(!mModeOn) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 187 | return true; |
| 188 | } |
| 189 | bool ret = true; |
| 190 | overlay::Overlay& ov = *(ctx->mOverlay); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 191 | ovutils::eDest dest = mDest; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 192 | int fd = hnd->fd; |
| 193 | uint32_t offset = hnd->offset; |
| 194 | if(mRot) { |
| 195 | if(!mRot->queueBuffer(fd, offset)) |
| 196 | return false; |
| 197 | fd = mRot->getDstMemId(); |
| 198 | offset = mRot->getDstOffset(); |
| 199 | } |
| 200 | if (!ov.queueBuffer(fd, offset, dest)) { |
Amara Venkata Mastan Manoj Kumar | dc01a53 | 2013-01-30 18:34:56 -0800 | [diff] [blame] | 201 | ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 202 | ret = false; |
| 203 | } |
| 204 | return ret; |
| 205 | } |
| 206 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 207 | //================= High res==================================== |
| 208 | FBUpdateHighRes::FBUpdateHighRes(const int& dpy): IFBUpdate(dpy) {} |
| 209 | |
| 210 | inline void FBUpdateHighRes::reset() { |
| 211 | IFBUpdate::reset(); |
| 212 | mDestLeft = ovutils::OV_INVALID; |
| 213 | mDestRight = ovutils::OV_INVALID; |
Arun Kumar K.R | ffef748 | 2013-04-10 14:17:22 -0700 | [diff] [blame] | 214 | mRot = NULL; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 215 | } |
| 216 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 217 | bool FBUpdateHighRes::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, |
| 218 | int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 219 | if(!ctx->mMDP.hasOverlay) { |
| 220 | ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 221 | __FUNCTION__); |
| 222 | return false; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 223 | } |
| 224 | ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 225 | mModeOn = configure(ctx, list, fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 226 | return mModeOn; |
| 227 | } |
| 228 | |
| 229 | // Configure |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 230 | bool FBUpdateHighRes::configure(hwc_context_t *ctx, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 231 | hwc_display_contents_1 *list, int fbZorder) { |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 232 | bool ret = false; |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 233 | hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 234 | if (LIKELY(ctx->mOverlay)) { |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 235 | int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; |
| 236 | // ext only layer present.. |
| 237 | if(extOnlyLayerIndex != -1) { |
| 238 | layer = &list->hwLayers[extOnlyLayerIndex]; |
| 239 | layer->compositionType = HWC_OVERLAY; |
| 240 | } |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 241 | overlay::Overlay& ov = *(ctx->mOverlay); |
| 242 | private_handle_t *hnd = (private_handle_t *)layer->handle; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 243 | ovutils::Whf info(hnd->width, hnd->height, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 244 | ovutils::getMdpFormat(hnd->format), hnd->size); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 245 | |
Saurabh Shah | c66f54d | 2013-06-12 15:45:59 -0700 | [diff] [blame] | 246 | //Request left pipe |
| 247 | ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 248 | if(destL == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 249 | ALOGE("%s: No pipes available to configure fb for dpy %d's left" |
| 250 | " mixer", __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 251 | return false; |
| 252 | } |
Saurabh Shah | c66f54d | 2013-06-12 15:45:59 -0700 | [diff] [blame] | 253 | //Request right pipe |
| 254 | ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 255 | if(destR == ovutils::OV_INVALID) { //None available |
Saurabh Shah | aa23682 | 2013-04-24 18:07:26 -0700 | [diff] [blame] | 256 | ALOGE("%s: No pipes available to configure fb for dpy %d's right" |
| 257 | " mixer", __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 258 | return false; |
| 259 | } |
| 260 | |
| 261 | mDestLeft = destL; |
| 262 | mDestRight = destR; |
| 263 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 264 | ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT; |
Sravan Kumar D.V.N | b5ed029 | 2013-03-15 08:51:16 +0530 | [diff] [blame] | 265 | |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 266 | ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 267 | |
| 268 | ovutils::PipeArgs pargL(mdpFlagsL, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 269 | info, |
| 270 | zOrder, |
| 271 | ovutils::IS_FG_OFF, |
| 272 | ovutils::ROT_FLAGS_NONE); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 273 | ov.setSource(pargL, destL); |
| 274 | |
| 275 | ovutils::eMdpFlags mdpFlagsR = mdpFlagsL; |
| 276 | ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER); |
| 277 | ovutils::PipeArgs pargR(mdpFlagsR, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 278 | info, |
| 279 | zOrder, |
| 280 | ovutils::IS_FG_OFF, |
| 281 | ovutils::ROT_FLAGS_NONE); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 282 | ov.setSource(pargR, destR); |
| 283 | |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 284 | hwc_rect_t sourceCrop = layer->sourceCrop; |
| 285 | hwc_rect_t displayFrame = layer->displayFrame; |
Ramkumar Radhakrishnan | 59a1107 | 2013-04-15 16:14:49 -0700 | [diff] [blame] | 286 | // Do not use getNonWormholeRegion() function to calculate the |
| 287 | // sourceCrop during animation on external display. |
| 288 | if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { |
| 289 | sourceCrop = layer->displayFrame; |
| 290 | displayFrame = sourceCrop; |
| 291 | } else if(extOnlyLayerIndex == -1) { |
Arun Kumar K.R | a297845 | 2013-02-07 01:34:24 -0800 | [diff] [blame] | 292 | getNonWormholeRegion(list, sourceCrop); |
| 293 | displayFrame = sourceCrop; |
| 294 | } |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 295 | |
| 296 | const float xres = ctx->dpyAttr[mDpy].xres; |
| 297 | //Default even split for all displays with high res |
| 298 | float lSplit = xres / 2; |
| 299 | if(mDpy == HWC_DISPLAY_PRIMARY && |
| 300 | qdutils::MDPVersion::getInstance().getLeftSplit()) { |
| 301 | //Override if split published by driver for primary |
| 302 | lSplit = qdutils::MDPVersion::getInstance().getLeftSplit(); |
| 303 | } |
| 304 | |
| 305 | const float lSplitRatio = lSplit / xres; |
| 306 | |
| 307 | const float lCropWidth = |
| 308 | (sourceCrop.right - sourceCrop.left) * lSplitRatio; |
| 309 | |
| 310 | ovutils::Dim dcropL( |
| 311 | sourceCrop.left, |
| 312 | sourceCrop.top, |
| 313 | lCropWidth, |
| 314 | sourceCrop.bottom - sourceCrop.top); |
| 315 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 316 | ovutils::Dim dcropR( |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 317 | sourceCrop.left + lCropWidth, |
| 318 | sourceCrop.top, |
| 319 | (sourceCrop.right - sourceCrop.left) - lCropWidth, |
| 320 | sourceCrop.bottom - sourceCrop.top); |
| 321 | |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 322 | ov.setCrop(dcropL, destL); |
| 323 | ov.setCrop(dcropR, destR); |
| 324 | |
| 325 | int transform = layer->transform; |
| 326 | ovutils::eTransform orient = |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 327 | static_cast<ovutils::eTransform>(transform); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 328 | ov.setTransform(orient, destL); |
| 329 | ov.setTransform(orient, destR); |
| 330 | |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 331 | const int lWidth = (lSplit - displayFrame.left); |
| 332 | const int rWidth = (displayFrame.right - lSplit); |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 333 | const int height = displayFrame.bottom - displayFrame.top; |
| 334 | |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 335 | ovutils::Dim dposL(displayFrame.left, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 336 | displayFrame.top, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 337 | lWidth, |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 338 | height); |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 339 | ov.setPosition(dposL, destL); |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 340 | |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 341 | ovutils::Dim dposR(0, |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 342 | displayFrame.top, |
Saurabh Shah | 67a38c3 | 2013-06-10 16:23:15 -0700 | [diff] [blame] | 343 | rWidth, |
Saurabh Shah | ce416f0 | 2013-04-10 13:33:09 -0700 | [diff] [blame] | 344 | height); |
Arun Kumar K.R | 0e8efb8 | 2013-03-18 17:31:50 -0700 | [diff] [blame] | 345 | ov.setPosition(dposR, destR); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 346 | |
| 347 | ret = true; |
| 348 | if (!ov.commit(destL)) { |
| 349 | ALOGE("%s: commit fails for left", __FUNCTION__); |
| 350 | ret = false; |
| 351 | } |
| 352 | if (!ov.commit(destR)) { |
| 353 | ALOGE("%s: commit fails for right", __FUNCTION__); |
| 354 | ret = false; |
| 355 | } |
| 356 | } |
| 357 | return ret; |
| 358 | } |
| 359 | |
Naseer Ahmed | 64b8121 | 2013-02-14 10:29:47 -0500 | [diff] [blame] | 360 | bool FBUpdateHighRes::draw(hwc_context_t *ctx, private_handle_t *hnd) |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 361 | { |
| 362 | if(!mModeOn) { |
| 363 | return true; |
| 364 | } |
| 365 | bool ret = true; |
| 366 | overlay::Overlay& ov = *(ctx->mOverlay); |
| 367 | ovutils::eDest destL = mDestLeft; |
| 368 | ovutils::eDest destR = mDestRight; |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 369 | if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) { |
| 370 | ALOGE("%s: queue failed for left of dpy = %d", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 371 | __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 372 | ret = false; |
| 373 | } |
| 374 | if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) { |
| 375 | ALOGE("%s: queue failed for right of dpy = %d", |
Jeykumar Sankaran | 85977e3 | 2013-02-25 17:06:08 -0800 | [diff] [blame] | 376 | __FUNCTION__, mDpy); |
Saurabh Shah | cf053c6 | 2012-12-13 12:32:55 -0800 | [diff] [blame] | 377 | ret = false; |
| 378 | } |
| 379 | return ret; |
| 380 | } |
| 381 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 382 | //--------------------------------------------------------------------- |
| 383 | }; //namespace qhwc |