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