overlayUtils.h revision 0dab964bf13bdd788234fc4eddd8690e6ba1ebeb
129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 2580dfd3c4aa61ffe48dc24dd4168ec8c2eb1cd43Sushil Chauhan* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. 329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Redistribution and use in source and binary forms, with or without 529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* modification, are permitted provided that the following conditions are 629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* met: 729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* * Redistributions of source code must retain the above copyright 829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* notice, this list of conditions and the following disclaimer. 929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* * Redistributions in binary form must reproduce the above 1029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* copyright notice, this list of conditions and the following 1129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* disclaimer in the documentation and/or other materials provided 1229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* with the distribution. 13a43fb8fce6d9be5577de1e0f49c99bd4fe2f6d44Duy Truong* * Neither the name of The Linux Foundation nor the names of its 1429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* contributors may be used to endorse or promote products derived 1529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* from this software without specific prior written permission. 1629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 1729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 1829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 2029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 2129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 2729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*/ 2929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 3029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifndef OVERLAY_UTILS_H 3129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define OVERLAY_UTILS_H 3229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <cutils/log.h> // ALOGE, etc 3429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <errno.h> 3529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <fcntl.h> // open, O_RDWR, etc 3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <hardware/hardware.h> 3729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <hardware/gralloc.h> // buffer_handle_t 38f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed#include <linux/msm_mdp.h> // flags 39f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah#include <linux/msm_rotator.h> 4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <stdio.h> 4129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <stdlib.h> 4229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <string.h> 4329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/stat.h> 4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/types.h> 4529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <utils/Log.h> 46f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed#include "gralloc_priv.h" //for interlace 47d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 48580dfd3c4aa61ffe48dc24dd4168ec8c2eb1cd43Sushil Chauhan// Older platforms do not support Venus. 49580dfd3c4aa61ffe48dc24dd4168ec8c2eb1cd43Sushil Chauhan#ifndef VENUS_COLOR_FORMAT 50d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan#define MDP_Y_CBCR_H2V2_VENUS (MDP_IMGTYPE_LIMIT2 + 1) 51d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan#endif 52d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan 5329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 5429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 5529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Collection of utilities functions/structs/enums etc... 5629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 5729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */ 5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// comment that out if you want to remove asserts 6029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// or put it as -D in Android.mk. your choice. 6129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define OVERLAY_HAS_ASSERT 6229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifdef OVERLAY_HAS_ASSERT 6429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed# define OVASSERT(x, ...) if(!(x)) { ALOGE(__VA_ARGS__); abort(); } 6529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#else 6629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed# define OVASSERT(x, ...) ALOGE_IF(!(x), __VA_ARGS__) 6729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // OVERLAY_HAS_ASSERT 6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define DEBUG_OVERLAY 0 7029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define PROFILE_OVERLAY 0 7129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 726457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#ifndef MDSS_MDP_RIGHT_MIXER 736457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#define MDSS_MDP_RIGHT_MIXER 0x100 746457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#endif 756457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah 766371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran#ifndef MDP_OV_PIPE_FORCE_DMA 776371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran#define MDP_OV_PIPE_FORCE_DMA 0x4000 786371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran#endif 796371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran 8029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace overlay { 8129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 8229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// fwd 8329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass Overlay; 84e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahclass OvFD; 85e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah 86e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah/* helper function to open by using fbnum */ 87e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahbool open(OvFD& fd, uint32_t fbnum, const char* const dev, 88e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah int flags = O_RDWR); 8929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 9029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace utils { 9129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Whf; 9229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Dim; 9329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 9429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t setBit(uint32_t x, uint32_t mask) { 9529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x | mask); 9629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 9729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 9829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t clrBit(uint32_t x, uint32_t mask) { 9929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x & ~mask); 10029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 10129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 10229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* Utility class to help avoid copying instances by making the copy ctor 10329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* and assignment operator private 10429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 10529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Usage: 106f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed* class SomeClass : utils::NoCopy {...}; 10729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*/ 10829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass NoCopy { 10929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprotected: 11029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed NoCopy(){} 11129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ~NoCopy() {} 11229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate: 11329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed NoCopy(const NoCopy&); 11429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed const NoCopy& operator=(const NoCopy&); 11529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 11629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 3D related utils, defines etc... 11929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * The compound format passed to the overlay is 12029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ABCCC where A is the input 3D format 12129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * B is the output 3D format 12229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * CCC is the color format e.g YCbCr420SP YCrCb420SP etc */ 12329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { SHIFT_OUT_3D = 12, 12429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed SHIFT_TOT_3D = 16 }; 12529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { INPUT_3D_MASK = 0xFFFF0000, 12629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OUTPUT_3D_MASK = 0x0000FFFF }; 12729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { BARRIER_LAND = 1, 12829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed BARRIER_PORT = 2 }; 12929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 130cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani/* if SurfaceFlinger process gets killed in bypass mode, In initOverlay() 131cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani * close all the pipes if it is opened after reboot. 132cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani */ 133cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudaniint initOverlay(void); 134cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani 13529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3D(uint32_t x) { return x & 0xFF000; } 13629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3DOutput(uint32_t x) { 13729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x & 0xF000) >> SHIFT_OUT_3D; } 13829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3DInput(uint32_t x) { return x & 0xF0000; } 13929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 14029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool isHDMIConnected (); 14129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool is3DTV(); 14229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool isPanel3D(); 14329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool usePanel3D(); 14429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool send3DInfoPacket (uint32_t fmt); 14529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool enableBarrier (uint32_t orientation); 14629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmeduint32_t getS3DFormat(uint32_t fmt); 147379167d52f574c0ddf0ac47272aec7dfd15929a1Sushil Chauhanbool isMdssRotator(); 148f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 14929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 150f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedbool getPositionS3D(const Whf& whf, Dim& out); 151f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 15229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 153f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedbool getCropS3D(const Dim& in, Dim& out, uint32_t fmt); 154f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 15529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class Type> 156f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedvoid swapWidthHeight(Type& width, Type& height); 15729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 15829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Dim { 15929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim () : x(0), y(0), 16029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(0), h(0), 16129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed o(0) {} 16229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim(uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h) : 16329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed x(_x), y(_y), 16429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(_w), h(_h) {} 16529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim(uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h, uint32_t _o) : 16629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed x(_x), y(_y), 16729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(_w), h(_h), 16829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed o(_o) {} 16929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool check(uint32_t _w, uint32_t _h) const { 17029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x+w <= _w && y+h <= _h); 17129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 17229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 17329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 17429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator==(const Dim& d) const { 17529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return d.x == x && d.y == y && 17629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed d.w == w && d.h == h && 17729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed d.o == o; 17829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 17929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 18029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator!=(const Dim& d) const { 18129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return !operator==(d); 18229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 18329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 18429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 18529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t x; 18629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t y; 18729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t w; 18829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t h; 18929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t o; 19029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 19129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 19229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// TODO have Whfz 19329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 19429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Whf { 19529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf() : w(0), h(0), format(0), size(0) {} 19629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf(uint32_t wi, uint32_t he, uint32_t f) : 19729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(wi), h(he), format(f), size(0) {} 19829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf(uint32_t wi, uint32_t he, uint32_t f, uint32_t s) : 19929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(wi), h(he), format(f), size(s) {} 20029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME not comparing size at the moment 20129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator==(const Whf& whf) const { 20229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return whf.w == w && whf.h == h && 20329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format == format; 20429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 20529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator!=(const Whf& whf) const { 20629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return !operator==(whf); 20729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 20829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 20929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t w; 21029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t h; 21129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t format; 21229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t size; 21329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 21429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 21529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { MAX_PATH_LEN = 256 }; 21629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 21729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/** 21829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Rotator flags: not to be confused with orientation flags. 21936963690317abceae79621f14ba41ff62b3ff489Saurabh Shah * Usually, you want to open the rotator to make sure it is 22029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ready for business. 22129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * */ 222d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan enum eRotFlags { 223d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_FLAGS_NONE = 0, 224d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan //Use rotator for 0 rotation. It is used anyway for others. 225d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_0_ENABLED = 1 << 0, 226d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan //Enable rotator downscale optimization for hardware bugs not handled in 227d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan //driver. If downscale optimizatation is required, 228d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan //then rotator will be used even if its 0 rotation case. 229d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_DOWNSCALE_ENABLED = 1 << 1, 23036963690317abceae79621f14ba41ff62b3ff489Saurabh Shah ROT_PREROTATED = 1 << 2, 231d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan}; 232d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan 233d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnanenum eRotDownscale { 234d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_DS_NONE = 0, 235d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_DS_HALF = 1, 236d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_DS_FOURTH = 2, 237d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ROT_DS_EIGHTH = 3, 23829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 23929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 24029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* The values for is_fg flag for control alpha and transp 24129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IS_FG_OFF means is_fg = 0 24229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IS_FG_SET means is_fg = 1 24329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed */ 24429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eIsFg { 24529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed IS_FG_OFF = 0, 24629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed IS_FG_SET = 1 24729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 24829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 24929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 25029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Various mdp flags like PIPE SHARE, DEINTERLACE etc... 25129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * kernel/common/linux/msm_mdp.h 25229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * INTERLACE_MASK: hardware/qcom/display/libgralloc/badger/fb_priv.h 25329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * */ 25429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eMdpFlags { 25529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_FLAGS_NONE = 0, 25629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_PIPE_SHARE = MDP_OV_PIPE_SHARE, 2576371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran OV_MDP_PIPE_FORCE_DMA = MDP_OV_PIPE_FORCE_DMA, 25829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_DEINTERLACE = MDP_DEINTERLACE, 259f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OV_MDP_SECURE_OVERLAY_SESSION = MDP_SECURE_OVERLAY_SESSION, 260f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OV_MDP_SOURCE_ROTATED_90 = MDP_SOURCE_ROTATED_90, 261799a39759ba03b08cb96ffb4bb7a2359a2959d93Saurabh Shah OV_MDP_BACKEND_COMPOSITION = MDP_BACKEND_COMPOSITION, 26291a6a994e8d799ea2d4c4cbe6ff2e9be76105988Saurabh Shah OV_MDP_BLEND_FG_PREMULT = MDP_BLEND_FG_PREMULT, 263e87b66d295a83b90e22bf4b7c48051eaea01ef75Saurabh Shah OV_MDP_FLIP_H = MDP_FLIP_LR, 264e87b66d295a83b90e22bf4b7c48051eaea01ef75Saurabh Shah OV_MDP_FLIP_V = MDP_FLIP_UD, 2656457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah OV_MDSS_MDP_RIGHT_MIXER = MDSS_MDP_RIGHT_MIXER, 26629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 26729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 26829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eZorder { 26936963690317abceae79621f14ba41ff62b3ff489Saurabh Shah ZORDER_0 = 0, 27029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ZORDER_1, 27129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ZORDER_2, 272d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed ZORDER_3, 27329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Z_SYSTEM_ALLOC = 0xFFFF 27429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 27529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 27629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eMdpPipeType { 27729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_PIPE_RGB, 278d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_MDP_PIPE_VG, 2796371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran OV_MDP_PIPE_DMA, 280d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_MDP_PIPE_ANY, //Any 28129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 28229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 283d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed/* Used to identify destination pipes 284d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed */ 28529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eDest { 286d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG0 = 0, 287d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB0, 288d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG1, 289d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB1, 290d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG2, 291d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB2, 2926371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran OV_DMA0, 2936371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran OV_DMA1, 294d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_INVALID, 295d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed}; 296d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 297d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed/* Used when a buffer is split over 2 pipes and sent to display */ 298d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedenum { 299d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_LEFT_SPLIT = 0, 300d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RIGHT_SPLIT, 30129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 30229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 30329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* values for copybit_set_parameter(OVERLAY_TRANSFORM) */ 30429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eTransform { 30529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* No rot */ 306f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_0 = 0x0, 307f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* flip source image horizontally 0x1 */ 308f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, 309f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* flip source image vertically 0x2 */ 310f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, 31129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate source image 180 degrees 31229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * It is basically bit-or-ed H | V == 0x3 */ 313f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, 314f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees 0x4 */ 315f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, 316f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees and flip horizontally 0x5 */ 317f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90_FLIP_H = HAL_TRANSFORM_ROT_90 | 318f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed HAL_TRANSFORM_FLIP_H, 319f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees and flip vertically 0x6 */ 320f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90_FLIP_V = HAL_TRANSFORM_ROT_90 | 321f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed HAL_TRANSFORM_FLIP_V, 32229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate source image 270 degrees 32329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Basically 180 | 90 == 0x7 */ 324f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, 32529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate invalid like in Transform.h */ 326f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_INV = 0x80 32729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 32829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 32929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// Used to consolidate pipe params 33029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct PipeArgs { 33129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed PipeArgs() : mdpFlags(OV_MDP_FLAGS_NONE), 33229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed zorder(Z_SYSTEM_ALLOC), 33329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed isFg(IS_FG_OFF), 334d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan rotFlags(ROT_FLAGS_NONE){ 33529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 33629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 337f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed PipeArgs(eMdpFlags f, Whf _whf, 33829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eZorder z, eIsFg fg, eRotFlags r) : 33929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mdpFlags(f), 34029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf(_whf), 34129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed zorder(z), 34229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed isFg(fg), 34329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed rotFlags(r) { 34429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 34529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 346f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed eMdpFlags mdpFlags; // for mdp_overlay flags 34729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf whf; 34829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eZorder zorder; // stage number 34929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eIsFg isFg; // control alpha & transp 35029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eRotFlags rotFlags; 35129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 35229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 35329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void setMdpFlags(eMdpFlags& f, eMdpFlags v) { 35429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed f = static_cast<eMdpFlags>(setBit(f, v)); 35529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 35629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 35729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void clearMdpFlags(eMdpFlags& f, eMdpFlags v) { 35829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed f = static_cast<eMdpFlags>(clrBit(f, v)); 35929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 36029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 36129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// fb 0/1/2 36229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { FB0, FB1, FB2 }; 36329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 36429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//Panels could be categorized as primary and external 36529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { PRIMARY, EXTERNAL }; 36629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 36729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// 2 for rgb0/1 double bufs 36829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { RGB_PIPE_NUM_BUFS = 2 }; 36929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 37029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct ScreenInfo { 37129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ScreenInfo() : mFBWidth(0), 37229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBHeight(0), 37329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBbpp(0), 37429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBystride(0) {} 37529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump(const char* const s) const; 37629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBWidth; 37729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBHeight; 37829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBbpp; 37929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBystride; 38029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 38129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 38229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedint getMdpFormat(int format); 3834e2cfc92692f8b9c03cb35702fa5ffeda0d29571Saurabh Shahint getHALFormat(int mdpFormat); 38436963690317abceae79621f14ba41ff62b3ff489Saurabh Shahint getDownscaleFactor(const int& src_w, const int& src_h, 38536963690317abceae79621f14ba41ff62b3ff489Saurabh Shah const int& dst_w, const int& dst_h); 3864e2cfc92692f8b9c03cb35702fa5ffeda0d29571Saurabh Shah 38729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* flip is upside down and such. V, H flip 38829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * rotation is 90, 180 etc 38929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * It returns MDP related enum/define that match rot+flip*/ 39029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedint getMdpOrient(eTransform rotation); 3919c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shahconst char* getFormatString(int format); 39229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 39329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// Cannot use HW_OVERLAY_MAGNIFICATION_LIMIT, since at the time 39429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// of integration, HW_OVERLAY_MAGNIFICATION_LIMIT was a define 39529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { HW_OV_MAGNIFICATION_LIMIT = 20, 39629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HW_OV_MINIFICATION_LIMIT = 8 39729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 39829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 39929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class T> 400f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline void memset0(T& t) { ::memset(&t, 0, sizeof(T)); } 40129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 40229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class T> inline void swap ( T& a, T& b ) 40329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 40429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed T c(a); a=b; b=c; 40529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 40629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 40729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int alignup(int value, int a) { 40829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed //if align = 0, return the value. Else, do alignment. 40929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return a ? ((((value - 1) / a) + 1) * a) : value; 41029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 41129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 412d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnaninline int aligndown(int value, int a) { 413d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan //if align = 0, return the value. Else, do alignment. 414d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan return a ? ((value) & ~(a-1)) : value; 415d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan} 416d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan 41729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FIXME that align should replace the upper one. 41829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int align(int value, int a) { 41929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed //if align = 0, return the value. Else, do alignment. 42029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return a ? ((value + (a-1)) & ~(a-1)) : value; 42129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 42229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 42329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eRotOutFmt { 42429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_OUT_FMT_DEFAULT, 42529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_OUT_FMT_Y_CRCB_H2V2 42629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 42729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 42829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int ROT_OUT_FMT> struct RotOutFmt; 42929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 43029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FIXME, taken from gralloc_priv.h. Need to 43129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// put it back as soon as overlay takes place of the old one 43229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* possible formats for 3D content*/ 43329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { 43429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_NO_3D = 0x0000, 43529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, 43629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_TOP_BOTTOM = 0x20000, 43729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_INTERLEAVE = 0x40000, 43829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_SIDE_BY_SIDE_R_L = 0x80000, 43929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_SIDE_BY_SIDE = 0x1000, 44029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOTTOM = 0x2000, 44129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERLEAVE = 0x4000, 44229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOSCOPIC = 0x8000 44329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 44429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 44529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { HAL_3D_OUT_SBS_MASK = 44629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_SIDE_BY_SIDE >> overlay::utils::SHIFT_OUT_3D, 44729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOT_MASK = 44829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOTTOM >> overlay::utils::SHIFT_OUT_3D, 44929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERL_MASK = 45029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERLEAVE >> overlay::utils::SHIFT_OUT_3D, 45129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOS_MASK = 45229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOSCOPIC >> overlay::utils::SHIFT_OUT_3D 45329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 45429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 45529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 45629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool isYuv(uint32_t format) { 45729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch(format){ 45829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V1: 45929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V2: 46029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CRCB_H2V2: 461b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CRCB_H1V1: 462b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CRCB_H2V1: 46329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CRCB_H2V2_TILE: 46429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V2_TILE: 465b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CR_CB_H2V2: 466ae1044e0cbab8d26851782e85525ee9e0e6127e6Saurabh Shah case MDP_Y_CR_CB_GH2V2: 467d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan case MDP_Y_CBCR_H2V2_VENUS: 46829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 46929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 47029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 47129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 47229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 47329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 47429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 47529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool isRgb(uint32_t format) { 47629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch(format) { 47729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGBA_8888: 47829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_BGRA_8888: 47929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGBX_8888: 48029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGB_565: 48129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 48229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 48329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 48429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 48529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 48629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 48729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 4889c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shahinline const char* getFormatString(int format){ 48929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const formats[] = { 49029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGB_565", 49129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_XRGB_8888", 49229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V2", 493f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H2V2_ADRENO", 49429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_ARGB_8888", 49529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGB_888", 49629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V2", 49729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_YCRYCB_H2V1", 49829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V1", 49929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V1", 500f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CRCB_H1V2", 501f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H1V2", 50229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGBA_8888", 50329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_BGRA_8888", 50429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGBX_8888", 50529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V2_TILE", 50629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V2_TILE", 50729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CR_CB_H2V2", 508f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CR_CB_GH2V2", 50929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CB_CR_H2V2", 510f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CRCB_H1V1", 511f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H1V1", 512f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_YCRCB_H1V1", 513f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_YCBCR_H1V1", 51429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_BGR_565", 515d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan "MDP_BGR_888", 516d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan "MDP_Y_CBCR_H2V2_VENUS", 517f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_IMGTYPE_LIMIT", 518f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_RGB_BORDERFILL", 51929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_FB_FORMAT", 52029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_IMGTYPE_LIMIT2" 52129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed }; 5229c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah if(format < 0 || format >= (int)(sizeof(formats) / sizeof(formats[0]))) { 5239c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah ALOGE("%s wrong fmt %d", __FUNCTION__, format); 5249c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah return "Unsupported format"; 5259c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah } 52629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return formats[format]; 52729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 52829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 52929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void Whf::dump() const { 53029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump WHF w=%d h=%d f=%d s=%d start/end ==", 53129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w, h, format, size); 53229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 53329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 53429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void Dim::dump() const { 53529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump Dim x=%d y=%d w=%d h=%d start/end ==", x, y, w, h); 53629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 53729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 53829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int getMdpOrient(eTransform rotation) { 53929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, rotation); 540f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed switch(rotation) 54129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 54229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case OVERLAY_TRANSFORM_0 : return 0; 543f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_FLIP_V: return MDP_FLIP_UD; 544f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_FLIP_H: return MDP_FLIP_LR; 545f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_90: return MDP_ROT_90; 546a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah //getMdpOrient will switch the flips if the source is 90 rotated. 547a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah //Clients in Android dont factor in 90 rotation while deciding flip. 548f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_90_FLIP_V: 549f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed return MDP_ROT_90 | MDP_FLIP_LR; 550a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah case OVERLAY_TRANSFORM_ROT_90_FLIP_H: 551a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah return MDP_ROT_90 | MDP_FLIP_UD; 552f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_180: return MDP_ROT_180; 553f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_270: return MDP_ROT_270; 55429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 555f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("%s: invalid rotation value (value = 0x%x", 556f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed __FUNCTION__, rotation); 55729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 55829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return -1; 55929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 56029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 56129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FB0 56229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 56329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline Dim getPositionS3DImpl(const Whf& whf) 56429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 56529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (whf.format & OUTPUT_3D_MASK) 56629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 56729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_SBS_MASK: 56829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // x, y, w, h 56929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w/2, whf.h); 57029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_TOP_BOT_MASK: 57129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w, whf.h/2); 57229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_MONOS_MASK: 57329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 57429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_INTERL_MASK: 57529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME error? 57629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_OUT_INTERLEAVE_MASK", __FUNCTION__); 57729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 57829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 57929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D output format %d", __FUNCTION__, 58029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format); 58129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 58229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 58329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 58429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 58529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <> 586d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline Dim getPositionS3DImpl<utils::OV_RIGHT_SPLIT>(const Whf& whf) 58729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 58829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (whf.format & OUTPUT_3D_MASK) 58929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 59029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_SBS_MASK: 59129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(whf.w/2, 0, whf.w/2, whf.h); 59229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_TOP_BOT_MASK: 59329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, whf.h/2, whf.w, whf.h/2); 59429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_MONOS_MASK: 59529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w, whf.h); 59629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_INTERL_MASK: 59729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME error? 59829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_OUT_INTERLEAVE_MASK", __FUNCTION__); 59929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 60029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 60129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D output format %d", __FUNCTION__, 60229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format); 60329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 60429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 60529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 60629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 60729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 60829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getPositionS3D(const Whf& whf, Dim& out) { 60929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed out = getPositionS3DImpl<CHAN>(whf); 61029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (out != Dim()); 61129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 61229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 61329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 61429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline Dim getCropS3DImpl(const Dim& in, uint32_t fmt) { 61529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (fmt & INPUT_3D_MASK) 61629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 61729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_L_R: 61829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w/2, in.h); 61929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_R_L: 62029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(in.w/2, 0, in.w/2, in.h); 62129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_TOP_BOTTOM: 62229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w, in.h/2); 62329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_INTERLEAVE: 62429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_IN_INTERLEAVE", __FUNCTION__); 62529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 62629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 62729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D format %d", __FUNCTION__, fmt); 62829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 62929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 63029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 63129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 63229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 63329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <> 634d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline Dim getCropS3DImpl<utils::OV_RIGHT_SPLIT>(const Dim& in, uint32_t fmt) { 63529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (fmt & INPUT_3D_MASK) 63629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 63729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_L_R: 63829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(in.w/2, 0, in.w/2, in.h); 63929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_R_L: 64029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w/2, in.h); 64129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_TOP_BOTTOM: 64229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, in.h/2, in.w, in.h/2); 64329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_INTERLEAVE: 64429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_IN_INTERLEAVE", __FUNCTION__); 64529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 64629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 64729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D format %d", __FUNCTION__, fmt); 64829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 64929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 65029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 65129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 65229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 65329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 65429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getCropS3D(const Dim& in, Dim& out, uint32_t fmt) 65529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 65629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed out = getCropS3DImpl<CHAN>(in, fmt); 65729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (out != Dim()); 65829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 65929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 66029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class Type> 66129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid swapWidthHeight(Type& width, Type& height) { 66229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Type tmp = width; 66329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed width = height; 66429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed height = tmp; 66529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 66629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 66729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void ScreenInfo::dump(const char* const s) const { 66829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump %s ScreenInfo w=%d h=%d" 66929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed " bpp=%d stride=%d start/end ==", 67029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, mFBWidth, mFBHeight, mFBbpp, mFBystride); 67129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 67229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 673e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahinline bool openDev(OvFD& fd, int fbnum, 674e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah const char* const devpath, int flags) { 675e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah return overlay::open(fd, fbnum, devpath, flags); 676e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah} 677e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah 678b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahtemplate <class T> 679b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahinline void even_ceil(T& value) { 680b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah if(value & 1) 681b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah value++; 682b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah} 683b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah 684b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahtemplate <class T> 685b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahinline void even_floor(T& value) { 686b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah if(value & 1) 687b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah value--; 688b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah} 689b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah 690d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline const char* getDestStr(eDest dest) { 691d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed switch(dest) { 692d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG0: return "VG0"; 693d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB0: return "RGB0"; 694d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG1: return "VG1"; 695d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB1: return "RGB1"; 696d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG2: return "VG2"; 697d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB2: return "RGB2"; 6986371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran case OV_DMA0: return "DMA0"; 6996371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran case OV_DMA1: return "DMA1"; 700d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed default: return "Invalid"; 701d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed } 702d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return "Invalid"; 703d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed} 704d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 705d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline eMdpPipeType getPipeType(eDest dest) { 706d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed switch(dest) { 707d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG0: 708d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG1: 709d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG2: 710d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_VG; 711d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB0: 712d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB1: 713d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB2: 714d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_RGB; 7156371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran case OV_DMA0: 7166371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran case OV_DMA1: 7176371fcefbcaf155e7402b3a7343d800470631d04Jeykumar Sankaran return OV_MDP_PIPE_DMA; 718d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed default: 719d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_ANY; 720d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed } 721d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_ANY; 722d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed} 723d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 7240dab964bf13bdd788234fc4eddd8690e6ba1ebebSaurabh Shahvoid preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop); 725f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, const mdp_overlay& ov); 726f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, const msmfb_img& ov); 727f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, const mdp_rect& ov); 728f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, 729f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah const msmfb_overlay_data& ov); 730f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, const msmfb_data& ov); 731f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, 732f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah const msm_rotator_img_info& ov); 733f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shahvoid getDump(char *buf, size_t len, const char *prefix, 734f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah const msm_rotator_data_info& ov); 735f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah 73629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // namespace utils ends 73729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 73829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------------Class Res stuff (namespace overlay only) ----------- 73929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 74029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass Res { 74129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic: 74229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /dev/graphics/fb%u 743f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed static const char* const fbPath; 74429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /dev/msm_rotator 74529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const rotPath; 74629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/class/graphics/fb1/format_3d 74729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const format3DFile; 74829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/class/graphics/fb1/3d_present 74929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const edid3dInfoFile; 75029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/devices/platform/mipi_novatek.0/enable_3d_barrier 75129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const barrierFile; 75229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 75329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 75429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 75529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------------Class OvFD stuff (namespace overlay only) ----------- 75629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 75729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 75829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Holds one FD 75929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Dtor will NOT close the underlying FD. 76029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* That enables us to copy that object around 76129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */ 76229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass OvFD { 76329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic: 76429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Ctor */ 76529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed explicit OvFD(); 76629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 76729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* dtor will NOT close the underlying FD */ 76829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ~OvFD(); 76929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 77029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Open fd using the path given by dev. 77129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * return false in failure */ 77229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool open(const char* const dev, 77329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int flags = O_RDWR); 77429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 77529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* populate path */ 77629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void setPath(const char* const dev); 77729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 77829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Close fd if we have a valid fd. */ 77929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool close(); 78029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 78129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* returns underlying fd.*/ 78229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int getFD() const; 78329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 78429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* returns true if fd is valid */ 78529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool valid() const; 78629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 78729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* like operator= */ 78829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void copy(int fd); 78929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* dump the state of the instance */ 79129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 79229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate: 79329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* helper enum for determine valid/invalid fd */ 79429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed enum { INVAL = -1 }; 79529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* actual os fd */ 79729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int mFD; 79829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* path, for debugging */ 80029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed char mPath[utils::MAX_PATH_LEN]; 80129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 80229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 80329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//-------------------Inlines-------------------------- 80429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 80529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool open(OvFD& fd, uint32_t fbnum, const char* const dev, int flags) 80629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 80729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed char dev_name[64] = {0}; 80829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed snprintf(dev_name, sizeof(dev_name), dev, fbnum); 80929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return fd.open(dev_name, flags); 81029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 81129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 81229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline OvFD::OvFD() : mFD (INVAL) { 81329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mPath[0] = 0; 81429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 81529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 816f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline OvFD::~OvFD() { 817f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed //no op since copy() can be used to share fd, in 3d cases. 818f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed} 81929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 82029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::open(const char* const dev, int flags) 82129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 82229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = ::open(dev, flags, 0); 82329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed if (mFD < 0) { 82429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME errno, strerror in bionic? 82529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("Cant open device %s err=%d", dev, errno); 82629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 82729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 82829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed setPath(dev); 82929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 83029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 83129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 83229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::setPath(const char* const dev) 83329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 83429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ::strncpy(mPath, dev, utils::MAX_PATH_LEN); 83529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 83629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 83729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::close() 83829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 83929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int ret = 0; 84029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed if(valid()) { 84129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ret = ::close(mFD); 84229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = INVAL; 84329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 84429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (ret == 0); 84529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 84629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 84729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::valid() const 84829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 84929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (mFD != INVAL); 85029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 85129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 85229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int OvFD::getFD() const { return mFD; } 85329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 85429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::copy(int fd) { 85529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = fd; 85629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 85729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 85829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::dump() const 85929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 86029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump OvFD fd=%d path=%s start/end ==", 86129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD, mPath); 86229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 86329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 86429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------- class OvFD stuff ends --------------------- 86529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 86629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // overlay 86729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 86829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 86929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // OVERLAY_UTILS_H 870