hwc_fbupdate.cpp revision 640cb9421639c13248aeb30c3496cdfaec6d894c
1ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed/* 2ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * Copyright (C) 2010 The Android Open Source Project 3bbee5b1c3475b630caa5061fbf535f87f21743f7Saurabh Shah * Copyright (C) 2012, The Linux Foundation. All rights reserved. 4ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * 5ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * Not a Contribution, Apache license notifications and license are 6ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * retained for attribution purposes only. 7ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * 8ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * Licensed under the Apache License, Version 2.0 (the "License"); 9ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * you may not use this file except in compliance with the License. 10ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * You may obtain a copy of the License at 11ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * 12ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * http://www.apache.org/licenses/LICENSE-2.0 13ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * 14ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * Unless required by applicable law or agreed to in writing, software 15ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * distributed under the License is distributed on an "AS IS" BASIS, 16ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * See the License for the specific language governing permissions and 18ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed * limitations under the License. 19ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed */ 20ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 21640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah#define DEBUG_FBUPDATE 0 221589dee5c27293d278d3e549af8a4bda27e080f8Naseer Ahmed#include <gralloc_priv.h> 231589dee5c27293d278d3e549af8a4bda27e080f8Naseer Ahmed#include <fb_priv.h> 2447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed#include "hwc_fbupdate.h" 25bbee5b1c3475b630caa5061fbf535f87f21743f7Saurabh Shah#include "external.h" 26ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 27ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmednamespace qhwc { 28ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 2947377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmednamespace ovutils = overlay::utils; 30ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 31640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh ShahIFBUpdate* IFBUpdate::getObject(const int& width, const int& dpy) { 32640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(width > MAX_DISPLAY_DIM) { 33640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return new FBUpdateHighRes(dpy); 34640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 35640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return new FBUpdateLowRes(dpy); 36640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 37640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 38640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahinline void IFBUpdate::reset() { 39640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mModeOn = false; 40640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 41640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 42640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah//================= Low res==================================== 43640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh ShahFBUpdateLowRes::FBUpdateLowRes(const int& dpy): IFBUpdate(dpy) {} 4447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed 45640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahinline void FBUpdateLowRes::reset() { 46640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah IFBUpdate::reset(); 47640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDest = ovutils::OV_INVALID; 48bbee5b1c3475b630caa5061fbf535f87f21743f7Saurabh Shah} 49ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 50640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateLowRes::prepare(hwc_context_t *ctx, hwc_layer_1_t *fblayer) { 51b3c6e058ce1dbc689f27e7d7acbf1529d37307d8Naseer Ahmed if(!ctx->mMDP.hasOverlay) { 52640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", 532e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah __FUNCTION__); 54080cfcaf2e972513fc09a0207d034ef5dcc975d8Naseer Ahmed return false; 55080cfcaf2e972513fc09a0207d034ef5dcc975d8Naseer Ahmed } 56640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mModeOn = configure(ctx, fblayer); 57640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); 58640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return mModeOn; 59ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 60ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 61ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed// Configure 62640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateLowRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer) 63ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed{ 6447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed bool ret = false; 6547377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed if (LIKELY(ctx->mOverlay)) { 6647377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed overlay::Overlay& ov = *(ctx->mOverlay); 6776443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 688cc5d853c3125df5867ce35a10d7a01dd51d48c6Saurabh Shah if (!hnd) { 698cc5d853c3125df5867ce35a10d7a01dd51d48c6Saurabh Shah ALOGE("%s:NULL private handle for layer!", __FUNCTION__); 708cc5d853c3125df5867ce35a10d7a01dd51d48c6Saurabh Shah return false; 718cc5d853c3125df5867ce35a10d7a01dd51d48c6Saurabh Shah } 7276443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size); 7347377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed 7447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed //Request an RGB pipe 75640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest dest = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy); 7647377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed if(dest == ovutils::OV_INVALID) { //None available 7747377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed return false; 7847377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed } 7947377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed 80640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDest = dest; 8176443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah 8276443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE; 8376443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah if(ctx->mSecureMode) { 8476443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::setMdpFlags(mdpFlags, 8576443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::OV_MDP_SECURE_OVERLAY_SESSION); 8676443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah } 87ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 8876443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::PipeArgs parg(mdpFlags, 8976443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah info, 9076443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::ZORDER_0, 9147377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ovutils::IS_FG_SET, 9276443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::ROT_FLAG_DISABLED); 9347377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ov.setSource(parg, dest); 9476443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah 9576443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah hwc_rect_t sourceCrop = layer->sourceCrop; 9676443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah // x,y,w,h 9776443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top, 982e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah sourceCrop.right - sourceCrop.left, 992e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah sourceCrop.bottom - sourceCrop.top); 10076443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ov.setCrop(dcrop, dest); 1012e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah 10276443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah int transform = layer->transform; 10376443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::eTransform orient = 10476443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah static_cast<ovutils::eTransform>(transform); 10576443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ov.setTransform(orient, dest); 106ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 10776443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah hwc_rect_t displayFrame = layer->displayFrame; 10876443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::Dim dpos(displayFrame.left, 1092e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah displayFrame.top, 1102e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah displayFrame.right - displayFrame.left, 1112e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah displayFrame.bottom - displayFrame.top); 11276443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ov.setPosition(dpos, dest); 1132e449280f98f003bb5831c274fc07ab722ac1a94Saurabh Shah 11447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = true; 11576443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah if (!ov.commit(dest)) { 11676443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ALOGE("%s: commit fails", __FUNCTION__); 11747377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = false; 118ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 119ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 12047377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed return ret; 121ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 122ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 123640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateLowRes::draw(hwc_context_t *ctx, hwc_layer_1_t *layer) 124ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed{ 125640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!mModeOn) { 126ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed return true; 127ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 128ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed bool ret = true; 12947377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed overlay::Overlay& ov = *(ctx->mOverlay); 130640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest dest = mDest; 13176443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 13247377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed if (!ov.queueBuffer(hnd->fd, hnd->offset, dest)) { 13347377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ALOGE("%s: queueBuffer failed for external", __FUNCTION__); 13447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = false; 135ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 136ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed return ret; 137ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 138ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 139640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah//================= High res==================================== 140640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh ShahFBUpdateHighRes::FBUpdateHighRes(const int& dpy): IFBUpdate(dpy) {} 141640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 142640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahinline void FBUpdateHighRes::reset() { 143640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah IFBUpdate::reset(); 144640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestLeft = ovutils::OV_INVALID; 145640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestRight = ovutils::OV_INVALID; 146640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 147640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 148640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateHighRes::prepare(hwc_context_t *ctx, hwc_layer_1_t *fblayer) { 149640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!ctx->mMDP.hasOverlay) { 150640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", 151640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah __FUNCTION__); 152640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 153640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 154640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); 155640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mModeOn = configure(ctx, fblayer); 156640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return mModeOn; 157640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 158640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 159640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah// Configure 160640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateHighRes::configure(hwc_context_t *ctx, hwc_layer_1_t *layer) 161640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah{ 162640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah bool ret = false; 163640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (LIKELY(ctx->mOverlay)) { 164640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah overlay::Overlay& ov = *(ctx->mOverlay); 165640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 166640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!hnd) { 167640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s:NULL private handle for layer!", __FUNCTION__); 168640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 169640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 170640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size); 171640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 172640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah //Request left RGB pipe 173640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy); 174640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(destL == ovutils::OV_INVALID) { //None available 175640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 176640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 177640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah //Request right RGB pipe 178640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, mDpy); 179640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(destR == ovutils::OV_INVALID) { //None available 180640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 181640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 182640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 183640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestLeft = destL; 184640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestRight = destR; 185640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 186640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_FLAGS_NONE; 187640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(ctx->mSecureMode) { 188640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::setMdpFlags(mdpFlagsL, 189640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::OV_MDP_SECURE_OVERLAY_SESSION); 190640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 191640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 192640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::PipeArgs pargL(mdpFlagsL, 193640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah info, 194640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::ZORDER_0, 195640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::IS_FG_SET, 196640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::ROT_FLAG_DISABLED); 197640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setSource(pargL, destL); 198640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 199640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eMdpFlags mdpFlagsR = mdpFlagsL; 200640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER); 201640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::PipeArgs pargR(mdpFlagsR, 202640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah info, 203640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::ZORDER_0, 204640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::IS_FG_SET, 205640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::ROT_FLAG_DISABLED); 206640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setSource(pargR, destR); 207640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 208640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah hwc_rect_t sourceCrop = layer->sourceCrop; 209640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::Dim dcropL(sourceCrop.left, sourceCrop.top, 210640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah (sourceCrop.right - sourceCrop.left) / 2, 211640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah sourceCrop.bottom - sourceCrop.top); 212640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::Dim dcropR( 213640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah sourceCrop.left + (sourceCrop.right - sourceCrop.left) / 2, 214640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah sourceCrop.top, 215640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah (sourceCrop.right - sourceCrop.left) / 2, 216640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah sourceCrop.bottom - sourceCrop.top); 217640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setCrop(dcropL, destL); 218640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setCrop(dcropR, destR); 219640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 220640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah int transform = layer->transform; 221640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eTransform orient = 222640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah static_cast<ovutils::eTransform>(transform); 223640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setTransform(orient, destL); 224640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setTransform(orient, destR); 225640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 226640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah hwc_rect_t displayFrame = layer->displayFrame; 227640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah //For FB left, top will always be 0 228640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah //That should also be the case if using 2 mixers for single display 229640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::Dim dpos(displayFrame.left, 230640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah displayFrame.top, 231640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah (displayFrame.right - displayFrame.left) / 2, 232640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah displayFrame.bottom - displayFrame.top); 233640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setPosition(dpos, destL); 234640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setPosition(dpos, destR); 235640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 236640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = true; 237640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.commit(destL)) { 238640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: commit fails for left", __FUNCTION__); 239640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 240640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 241640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.commit(destR)) { 242640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: commit fails for right", __FUNCTION__); 243640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 244640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 245640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 246640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return ret; 247640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 248640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 249640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahbool FBUpdateHighRes::draw(hwc_context_t *ctx, hwc_layer_1_t *layer) 250640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah{ 251640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!mModeOn) { 252640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return true; 253640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 254640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah bool ret = true; 255640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah overlay::Overlay& ov = *(ctx->mOverlay); 256640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destL = mDestLeft; 257640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destR = mDestRight; 258640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 259640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) { 260640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: queue failed for left of dpy = %d", 261640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah __FUNCTION__, mDpy); 262640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 263640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 264640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) { 265640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: queue failed for right of dpy = %d", 266640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah __FUNCTION__, mDpy); 267640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 268640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 269640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return ret; 270640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 271640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 272ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed//--------------------------------------------------------------------- 273ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed}; //namespace qhwc 274