hwc_fbupdate.cpp revision f8c680dacf0a357ea1f56542fb329bbc9749b6b5
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 223b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R#include <cutils/properties.h> 231589dee5c27293d278d3e549af8a4bda27e080f8Naseer Ahmed#include <gralloc_priv.h> 241a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah#include <overlay.h> 253b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R#include <overlayRotator.h> 2647377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed#include "hwc_fbupdate.h" 278fe8c938d27e528fcf7fb4a408711b4b6e405f13Saurabh Shah#include "mdp_version.h" 283b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R#include "external.h" 29fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumar#include "virtual.h" 308fe8c938d27e528fcf7fb4a408711b4b6e405f13Saurabh Shah 318fe8c938d27e528fcf7fb4a408711b4b6e405f13Saurabh Shahusing namespace qdutils; 321a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shahusing namespace overlay; 333b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.Rusing overlay::Rotator; 34fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumarusing namespace overlay::utils; 353b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R 36ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmednamespace qhwc { 37ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 3847377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmednamespace ovutils = overlay::utils; 39ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 40f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh ShahIFBUpdate* IFBUpdate::getObject(hwc_context_t *ctx, const int& dpy) { 41f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah if(isDisplaySplit(ctx, dpy)) { 42f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return new FBUpdateSplit(dpy); 43640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 44f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shah return new FBUpdateNonSplit(dpy); 45640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 46640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 47640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shahinline void IFBUpdate::reset() { 48640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mModeOn = false; 493b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R mRot = NULL; 50640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 51640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 52640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah//================= Low res==================================== 53f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh ShahFBUpdateNonSplit::FBUpdateNonSplit(const int& dpy): IFBUpdate(dpy) {} 5447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed 55f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahinline void FBUpdateNonSplit::reset() { 56640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah IFBUpdate::reset(); 57640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDest = ovutils::OV_INVALID; 58bbee5b1c3475b630caa5061fbf535f87f21743f7Saurabh Shah} 59ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 60f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateNonSplit::preRotateExtDisplay(hwc_context_t *ctx, 6197c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ovutils::Whf &info, 6297c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan hwc_rect_t& sourceCrop, 6397c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ovutils::eMdpFlags& mdpFlags, 6497c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan int& rotFlags) 6597c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan{ 6697c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan int extOrient = getExtOrientation(ctx); 6797c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ovutils::eTransform orient = static_cast<ovutils::eTransform >(extOrient); 6897c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) { 6997c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan mRot = ctx->mRotMgr->getNext(); 7097c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan if(mRot == NULL) return false; 7197c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan //Configure rotator for pre-rotation 7297c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan if(configRotator(mRot, info, sourceCrop, mdpFlags, orient, 0) < 0) { 7397c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ALOGE("%s: configRotator Failed!", __FUNCTION__); 7497c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan mRot = NULL; 7597c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan return false; 7697c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan } 7797c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan info.format = (mRot)->getDstFormat(); 7897c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan updateSource(orient, info, sourceCrop); 7997c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan rotFlags |= ovutils::ROT_PREROTATED; 8097c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan } 8197c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan return true; 8297c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan} 8397c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan 84f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateNonSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, 85f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int fbZorder) { 86b3c6e058ce1dbc689f27e7d7acbf1529d37307d8Naseer Ahmed if(!ctx->mMDP.hasOverlay) { 87640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", 88f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__); 89f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 90080cfcaf2e972513fc09a0207d034ef5dcc975d8Naseer Ahmed } 91f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mModeOn = configure(ctx, list, fbZorder); 92640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return mModeOn; 93ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 94ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 95ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed// Configure 96f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateNonSplit::configure(hwc_context_t *ctx, hwc_display_contents_1 *list, 97f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int fbZorder) { 9847377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed bool ret = false; 9904a2afbd65e9f8bc580a637bf44bfc4e627edce0Naseer Ahmed hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; 10047377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed if (LIKELY(ctx->mOverlay)) { 101eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; 102eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R // ext only layer present.. 103eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R if(extOnlyLayerIndex != -1) { 104eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R layer = &list->hwLayers[extOnlyLayerIndex]; 105eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R layer->compositionType = HWC_OVERLAY; 106eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R } 10747377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed overlay::Overlay& ov = *(ctx->mOverlay); 10876443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 109327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah ovutils::Whf info(hnd->width, hnd->height, 110f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::getMdpFormat(hnd->format), hnd->size); 11147377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed 11256d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah //Request a pipe 11356d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah ovutils::eMdpPipeType type = ovutils::OV_MDP_PIPE_ANY; 11456d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah if(qdutils::MDPVersion::getInstance().is8x26() && mDpy) { 11556d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah //For 8x26 external always use DMA pipe 11656d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah type = ovutils::OV_MDP_PIPE_DMA; 11756d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah } 1181a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah ovutils::eDest dest = ov.nextPipe(type, mDpy, Overlay::MIXER_DEFAULT); 11947377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed if(dest == ovutils::OV_INVALID) { //None available 120af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ALOGE("%s: No pipes available to configure fb for dpy %d", 121af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah __FUNCTION__, mDpy); 12247377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed return false; 12347377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed } 124640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDest = dest; 12576443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah 1269f69b91e962b59f708dac458f24b11c4c4b94348Ramkumar Radhakrishnan if((mDpy && ctx->deviceOrientation) && 1279f69b91e962b59f708dac458f24b11c4c4b94348Ramkumar Radhakrishnan ctx->listStats[mDpy].isDisplayAnimating) { 1289f69b91e962b59f708dac458f24b11c4c4b94348Ramkumar Radhakrishnan fbZorder = 0; 1299f69b91e962b59f708dac458f24b11c4c4b94348Ramkumar Radhakrishnan } 1309f69b91e962b59f708dac458f24b11c4c4b94348Ramkumar Radhakrishnan 131f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_BLEND_FG_PREMULT; 1323b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R ovutils::eIsFg isFg = ovutils::IS_FG_OFF; 133f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); 134ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 135eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R hwc_rect_t sourceCrop = layer->sourceCrop; 136eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R hwc_rect_t displayFrame = layer->displayFrame; 13776443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah int transform = layer->transform; 1383b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R int rotFlags = ovutils::ROT_FLAGS_NONE; 1393b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R 14076443245d153635b512539fbc68fdf7a904fdf6fSaurabh Shah ovutils::eTransform orient = 1413b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R static_cast<ovutils::eTransform>(transform); 142effbd25d502916fcdebadd1d2b83988559434e79Arun Kumar K.R // use ext orientation if any 14397c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan int extOrient = getExtOrientation(ctx); 144ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 145a0e87cbc523323604e8fb7cb5526f410a1ed26dfRamkumar Radhakrishnan // Do not use getNonWormholeRegion() function to calculate the 146a0e87cbc523323604e8fb7cb5526f410a1ed26dfRamkumar Radhakrishnan // sourceCrop during animation on external display and 1473b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R // Dont do wormhole calculation when extorientation is set on External 148fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumar // Dont do wormhole calculation when extDownscale is enabled on External 149a0e87cbc523323604e8fb7cb5526f410a1ed26dfRamkumar Radhakrishnan if(ctx->listStats[mDpy].isDisplayAnimating && mDpy) { 150a0e87cbc523323604e8fb7cb5526f410a1ed26dfRamkumar Radhakrishnan sourceCrop = layer->displayFrame; 151a0e87cbc523323604e8fb7cb5526f410a1ed26dfRamkumar Radhakrishnan displayFrame = sourceCrop; 152fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumar } else if((!mDpy || 153effbd25d502916fcdebadd1d2b83988559434e79Arun Kumar K.R (mDpy && !extOrient 154fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumar && !ctx->dpyAttr[mDpy].mDownScaleMode)) 155fea63d61337f1efeb2d1c7a7a4fafe472611704cAmara Venkata Mastan Manoj Kumar && (extOnlyLayerIndex == -1)) { 15656d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah if(!qdutils::MDPVersion::getInstance().is8x26()) { 15756d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah getNonWormholeRegion(list, sourceCrop); 15856d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah displayFrame = sourceCrop; 15956d570f1d7eb34ab0db968298efb8e75b849c893Saurabh Shah } 1603b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R } 16197c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan calcExtDisplayPosition(ctx, hnd, mDpy, sourceCrop, displayFrame, 16297c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan transform, orient); 1633e76f19cb2c0441315ebe54110f7b452d2932f52Ramkumar Radhakrishnan setMdpFlags(layer, mdpFlags, 0, transform); 1643b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R // For External use rotator if there is a rotation value set 16597c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ret = preRotateExtDisplay(ctx, info, sourceCrop, mdpFlags, rotFlags); 16697c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan if(!ret) { 16797c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan ALOGE("%s: preRotate for external Failed!", __FUNCTION__); 16897c10c26c62d57a3fc31197fdd37d1bbfb8d1c2aRamkumar Radhakrishnan return false; 1693b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R } 1703b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R //For the mdp, since either we are pre-rotating or MDP does flips 1713b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R orient = ovutils::OVERLAY_TRANSFORM_0; 1723b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R transform = 0; 1733b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R ovutils::PipeArgs parg(mdpFlags, info, zOrder, isFg, 17412a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed static_cast<ovutils::eRotFlags>(rotFlags), 17512a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed ovutils::DEFAULT_PLANE_ALPHA, 17612a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed (ovutils::eBlending) 17712a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed getBlending(layer->blending)); 17847377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = true; 1793b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R if(configMdp(ctx->mOverlay, parg, orient, sourceCrop, displayFrame, 1803b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R NULL, mDest) < 0) { 181e188278e86ebb2f7f1ed3762855f15062b7f9d03Saurabh Shah ALOGE("%s: configMdp failed for dpy %d", __FUNCTION__, mDpy); 18247377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = false; 183ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 184ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 18547377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed return ret; 186ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 187ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 188f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateNonSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) 189ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed{ 190640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!mModeOn) { 191ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed return true; 192ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 193ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed bool ret = true; 19447377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed overlay::Overlay& ov = *(ctx->mOverlay); 195640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest dest = mDest; 1963b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R int fd = hnd->fd; 1973b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R uint32_t offset = hnd->offset; 1983b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R if(mRot) { 1993b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R if(!mRot->queueBuffer(fd, offset)) 2003b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R return false; 2013b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R fd = mRot->getDstMemId(); 2023b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R offset = mRot->getDstOffset(); 2033b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R } 2043b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R if (!ov.queueBuffer(fd, offset, dest)) { 2059513fc6f6c9a7eb26a57838c6bbe95ecd29a7ca5Amara Venkata Mastan Manoj Kumar ALOGE("%s: queueBuffer failed for FBUpdate", __FUNCTION__); 20647377987cc4eef72ee3b0cdced8c3a15038b39ebNaseer Ahmed ret = false; 207ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed } 208ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed return ret; 209ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed} 210ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed 211640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah//================= High res==================================== 212f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh ShahFBUpdateSplit::FBUpdateSplit(const int& dpy): IFBUpdate(dpy) {} 213640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 214f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahinline void FBUpdateSplit::reset() { 215640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah IFBUpdate::reset(); 216640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestLeft = ovutils::OV_INVALID; 217640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestRight = ovutils::OV_INVALID; 2183b9570a337a3115ad05dee3c1aa2ecc6f82f6ab1Arun Kumar K.R mRot = NULL; 219640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 220640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 221f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateSplit::prepare(hwc_context_t *ctx, hwc_display_contents_1 *list, 222f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran int fbZorder) { 223640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!ctx->mMDP.hasOverlay) { 224640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, this hw doesnt support overlays", 225f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__); 226f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran return false; 227640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 228640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGD_IF(DEBUG_FBUPDATE, "%s, mModeOn = %d", __FUNCTION__, mModeOn); 229f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran mModeOn = configure(ctx, list, fbZorder); 230640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return mModeOn; 231640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 232640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 233640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah// Configure 234f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateSplit::configure(hwc_context_t *ctx, 2352e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah hwc_display_contents_1 *list, int fbZorder) { 236640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah bool ret = false; 23704a2afbd65e9f8bc580a637bf44bfc4e627edce0Naseer Ahmed hwc_layer_1_t *layer = &list->hwLayers[list->numHwLayers - 1]; 238640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (LIKELY(ctx->mOverlay)) { 239eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R int extOnlyLayerIndex = ctx->listStats[mDpy].extOnlyLayerIndex; 240eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R // ext only layer present.. 241eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R if(extOnlyLayerIndex != -1) { 242eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R layer = &list->hwLayers[extOnlyLayerIndex]; 243eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R layer->compositionType = HWC_OVERLAY; 244eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R } 245640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah overlay::Overlay& ov = *(ctx->mOverlay); 246640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah private_handle_t *hnd = (private_handle_t *)layer->handle; 247327b2ba85538669304a50d0fb6cc2f6aab7aaf3bSaurabh Shah ovutils::Whf info(hnd->width, hnd->height, 248f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::getMdpFormat(hnd->format), hnd->size); 249640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 25065e9330208dae69762bd3fc81587b8552eaaf739Saurabh Shah //Request left pipe 2511a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah ovutils::eDest destL = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy, 2521a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah Overlay::MIXER_LEFT); 253640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(destL == ovutils::OV_INVALID) { //None available 254af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ALOGE("%s: No pipes available to configure fb for dpy %d's left" 255af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah " mixer", __FUNCTION__, mDpy); 256640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 257640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 25865e9330208dae69762bd3fc81587b8552eaaf739Saurabh Shah //Request right pipe 2591a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah ovutils::eDest destR = ov.nextPipe(ovutils::OV_MDP_PIPE_ANY, mDpy, 2601a36c7e14d1628592e4e1cff96d977b829f8cc31Saurabh Shah Overlay::MIXER_RIGHT); 261640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(destR == ovutils::OV_INVALID) { //None available 262af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah ALOGE("%s: No pipes available to configure fb for dpy %d's right" 263af5f82d1c39754b14e9fc91eedc0d0429020c049Saurabh Shah " mixer", __FUNCTION__, mDpy); 264640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return false; 265640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 266640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 267640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestLeft = destL; 268640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah mDestRight = destR; 269640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 270f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::eMdpFlags mdpFlagsL = ovutils::OV_MDP_BLEND_FG_PREMULT; 2715c937230915bced21130a3e5d129c4f470fd74d3Sravan Kumar D.V.N 272f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::eZorder zOrder = static_cast<ovutils::eZorder>(fbZorder); 273640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 27412a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed //XXX: FB layer plane alpha is currently sent as zero from 27512a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed //surfaceflinger 276640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::PipeArgs pargL(mdpFlagsL, 277f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran info, 278f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran zOrder, 279f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::IS_FG_OFF, 28012a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed ovutils::ROT_FLAGS_NONE, 28112a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed ovutils::DEFAULT_PLANE_ALPHA, 28212a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed (ovutils::eBlending) 28312a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed getBlending(layer->blending)); 284640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setSource(pargL, destL); 285640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 286640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eMdpFlags mdpFlagsR = mdpFlagsL; 287640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::setMdpFlags(mdpFlagsR, ovutils::OV_MDSS_MDP_RIGHT_MIXER); 288640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::PipeArgs pargR(mdpFlagsR, 289f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran info, 290f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran zOrder, 291f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran ovutils::IS_FG_OFF, 29212a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed ovutils::ROT_FLAGS_NONE, 29312a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed ovutils::DEFAULT_PLANE_ALPHA, 29412a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed (ovutils::eBlending) 29512a7b537b1e043a61b06db3d083c2372c11ef1f2Naseer Ahmed getBlending(layer->blending)); 296640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setSource(pargR, destR); 297640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 298eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R hwc_rect_t sourceCrop = layer->sourceCrop; 299eb43d2b7b681164a58e3f86bd0b0d88eea6a3591Arun Kumar K.R hwc_rect_t displayFrame = layer->displayFrame; 3002e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah 3012e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah const float xres = ctx->dpyAttr[mDpy].xres; 3029640e380d8f815ef7ca71c1fdf23eb6f7b30db1eSaurabh Shah const int lSplit = getLeftSplit(ctx, mDpy); 3032e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah const float lSplitRatio = lSplit / xres; 3042e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah const float lCropWidth = 3052e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah (sourceCrop.right - sourceCrop.left) * lSplitRatio; 3062e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah 3072e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah ovutils::Dim dcropL( 3082e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.left, 3092e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.top, 3102e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah lCropWidth, 3112e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.bottom - sourceCrop.top); 3122e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah 313640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::Dim dcropR( 3142e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.left + lCropWidth, 3152e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.top, 3162e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah (sourceCrop.right - sourceCrop.left) - lCropWidth, 3172e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah sourceCrop.bottom - sourceCrop.top); 3182e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah 319640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setCrop(dcropL, destL); 320640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setCrop(dcropR, destR); 321640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 322640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah int transform = layer->transform; 323640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eTransform orient = 324f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran static_cast<ovutils::eTransform>(transform); 325640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setTransform(orient, destL); 326640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ov.setTransform(orient, destR); 327640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 3282e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah const int lWidth = (lSplit - displayFrame.left); 3292e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah const int rWidth = (displayFrame.right - lSplit); 330c515b0f37640828e8d9c1d9d7fef0d452684fec4Saurabh Shah const int height = displayFrame.bottom - displayFrame.top; 331c515b0f37640828e8d9c1d9d7fef0d452684fec4Saurabh Shah 3322e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah ovutils::Dim dposL(displayFrame.left, 333f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran displayFrame.top, 3342e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah lWidth, 335c515b0f37640828e8d9c1d9d7fef0d452684fec4Saurabh Shah height); 33693f93515d4b36db7ddb56da15563e3ea6e7ce18cArun Kumar K.R ov.setPosition(dposL, destL); 337c515b0f37640828e8d9c1d9d7fef0d452684fec4Saurabh Shah 33893f93515d4b36db7ddb56da15563e3ea6e7ce18cArun Kumar K.R ovutils::Dim dposR(0, 339f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran displayFrame.top, 3402e474227e216ee37ab84a3c9a22ea1f650626231Saurabh Shah rWidth, 341c515b0f37640828e8d9c1d9d7fef0d452684fec4Saurabh Shah height); 34293f93515d4b36db7ddb56da15563e3ea6e7ce18cArun Kumar K.R ov.setPosition(dposR, destR); 343640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 344640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = true; 345640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.commit(destL)) { 346640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: commit fails for left", __FUNCTION__); 347640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 348640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 349640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.commit(destR)) { 350640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: commit fails for right", __FUNCTION__); 351640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 352640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 353640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 354640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return ret; 355640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 356640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 357f8c680dacf0a357ea1f56542fb329bbc9749b6b5Saurabh Shahbool FBUpdateSplit::draw(hwc_context_t *ctx, private_handle_t *hnd) 358640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah{ 359640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if(!mModeOn) { 360640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return true; 361640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 362640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah bool ret = true; 363640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah overlay::Overlay& ov = *(ctx->mOverlay); 364640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destL = mDestLeft; 365640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ovutils::eDest destR = mDestRight; 366640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.queueBuffer(hnd->fd, hnd->offset, destL)) { 367640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: queue failed for left of dpy = %d", 368f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__, mDpy); 369640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 370640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 371640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah if (!ov.queueBuffer(hnd->fd, hnd->offset, destR)) { 372640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ALOGE("%s: queue failed for right of dpy = %d", 373f9572cdbe3541d85522adea584f925671b375300Jeykumar Sankaran __FUNCTION__, mDpy); 374640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah ret = false; 375640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah } 376640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah return ret; 377640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah} 378640cb9421639c13248aeb30c3496cdfaec6d894cSaurabh Shah 379ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed//--------------------------------------------------------------------- 380ccf943e44f9e9d615a6019459625148830039f8dNaseer Ahmed}; //namespace qhwc 381