overlayUtils.h revision 6457316fc7ae8ea29d763edce3fc1ffc78dd7387
129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 256f610dd235b577725198e9341caae92379fdf23Saurabh Shah* Copyright (c) 2011-2012, 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. 1329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* * Neither the name of Code Aurora Forum, Inc. 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 3929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <stdio.h> 4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <stdlib.h> 4129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <string.h> 4229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/stat.h> 4329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/types.h> 4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <utils/Log.h> 45f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed#include "gralloc_priv.h" //for interlace 46d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 47d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan#ifndef MDP_Y_CBCR_H2V2_VENUS 48d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan#define MDP_Y_CBCR_H2V2_VENUS (MDP_IMGTYPE_LIMIT2 + 1) 49d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan#endif 50d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan 5129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 5229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 5329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Collection of utilities functions/structs/enums etc... 5429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 5529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */ 5629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// comment that out if you want to remove asserts 5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// or put it as -D in Android.mk. your choice. 5929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define OVERLAY_HAS_ASSERT 6029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifdef OVERLAY_HAS_ASSERT 6229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed# define OVASSERT(x, ...) if(!(x)) { ALOGE(__VA_ARGS__); abort(); } 6329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#else 6429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed# define OVASSERT(x, ...) ALOGE_IF(!(x), __VA_ARGS__) 6529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // OVERLAY_HAS_ASSERT 6629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define DEBUG_OVERLAY 0 6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define PROFILE_OVERLAY 0 6929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 706457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#ifndef MDSS_MDP_RIGHT_MIXER 716457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#define MDSS_MDP_RIGHT_MIXER 0x100 726457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah#endif 736457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah 7429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace overlay { 7529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 7629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// fwd 7729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass Overlay; 78e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahclass OvFD; 79e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah 80e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah/* helper function to open by using fbnum */ 81e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahbool open(OvFD& fd, uint32_t fbnum, const char* const dev, 82e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah int flags = O_RDWR); 8329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 8429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace utils { 8529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Whf; 8629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Dim; 8729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 8829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t setBit(uint32_t x, uint32_t mask) { 8929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x | mask); 9029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 9129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 9229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t clrBit(uint32_t x, uint32_t mask) { 9329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x & ~mask); 9429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 9529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 9629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* Utility class to help avoid copying instances by making the copy ctor 9729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* and assignment operator private 9829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 9929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Usage: 100f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed* class SomeClass : utils::NoCopy {...}; 10129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*/ 10229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass NoCopy { 10329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprotected: 10429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed NoCopy(){} 10529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ~NoCopy() {} 10629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate: 10729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed NoCopy(const NoCopy&); 10829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed const NoCopy& operator=(const NoCopy&); 10929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 11029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 11229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Utility class to query the framebuffer info for primary display 11329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* 11429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Usage: 11529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Outside of functions: 11629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* utils::FrameBufferInfo* utils::FrameBufferInfo::sFBInfoInstance = 0; 11729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Inside functions: 11829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* utils::FrameBufferInfo::getInstance()->supportTrueMirroring() 11929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*/ 12029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass FrameBufferInfo { 12129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 12229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic: 12329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* ctor init */ 12429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed explicit FrameBufferInfo(); 12529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 12629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Gets an instance if one does not already exist */ 12729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static FrameBufferInfo* getInstance(); 12829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 12929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Gets width of primary framebuffer */ 13029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int getWidth() const; 13129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 13229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Gets height of primary framebuffer */ 13329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int getHeight() const; 13429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 13529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate: 13629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int mFBWidth; 13729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int mFBHeight; 13829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool mBorderFillSupported; 13929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static FrameBufferInfo *sFBInfoInstance; 14029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 14129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 14229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 3D related utils, defines etc... 14329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * The compound format passed to the overlay is 14429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ABCCC where A is the input 3D format 14529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * B is the output 3D format 14629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * CCC is the color format e.g YCbCr420SP YCrCb420SP etc */ 14729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { SHIFT_OUT_3D = 12, 14829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed SHIFT_TOT_3D = 16 }; 14929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { INPUT_3D_MASK = 0xFFFF0000, 15029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OUTPUT_3D_MASK = 0x0000FFFF }; 15129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { BARRIER_LAND = 1, 15229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed BARRIER_PORT = 2 }; 15329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 154cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani/* if SurfaceFlinger process gets killed in bypass mode, In initOverlay() 155cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani * close all the pipes if it is opened after reboot. 156cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani */ 157cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudaniint initOverlay(void); 158cb3da0a5e4313f55bd27514006c3ce64293ff8a2Ajay Dudani 15929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3D(uint32_t x) { return x & 0xFF000; } 160f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline uint32_t colorFormat(uint32_t fmt) { 161f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /*TODO enable this block only if format has interlace / 3D info in top bits. 162f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if(fmt & INTERLACE_MASK) { 163f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed fmt = fmt ^ HAL_PIXEL_FORMAT_INTERLACE; 164f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed } 165f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed fmt = fmt & 0xFFF;*/ 166f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed return fmt; 167f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed} 16829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3DOutput(uint32_t x) { 16929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x & 0xF000) >> SHIFT_OUT_3D; } 17029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t format3DInput(uint32_t x) { return x & 0xF0000; } 17129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmeduint32_t getColorFormat(uint32_t format); 17229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 17329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool isHDMIConnected (); 17429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool is3DTV(); 17529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool isPanel3D(); 17629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool usePanel3D(); 17729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool send3DInfoPacket (uint32_t fmt); 17829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool enableBarrier (uint32_t orientation); 17929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmeduint32_t getS3DFormat(uint32_t fmt); 180f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 18129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 182f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedbool getPositionS3D(const Whf& whf, Dim& out); 183f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 18429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 185f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedbool getCropS3D(const Dim& in, Dim& out, uint32_t fmt); 186f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed 18729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class Type> 188f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedvoid swapWidthHeight(Type& width, Type& height); 18929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 19029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Dim { 19129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim () : x(0), y(0), 19229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(0), h(0), 19329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed o(0) {} 19429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim(uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h) : 19529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed x(_x), y(_y), 19629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(_w), h(_h) {} 19729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Dim(uint32_t _x, uint32_t _y, uint32_t _w, uint32_t _h, uint32_t _o) : 19829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed x(_x), y(_y), 19929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(_w), h(_h), 20029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed o(_o) {} 20129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool check(uint32_t _w, uint32_t _h) const { 20229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (x+w <= _w && y+h <= _h); 20329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 20429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 20529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 20629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator==(const Dim& d) const { 20729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return d.x == x && d.y == y && 20829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed d.w == w && d.h == h && 20929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed d.o == o; 21029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 21129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 21229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator!=(const Dim& d) const { 21329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return !operator==(d); 21429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 21529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 21629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 21729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t x; 21829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t y; 21929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t w; 22029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t h; 22129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t o; 22229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 22329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 22429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// TODO have Whfz 22529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 22629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct Whf { 22729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf() : w(0), h(0), format(0), size(0) {} 22829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf(uint32_t wi, uint32_t he, uint32_t f) : 22929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(wi), h(he), format(f), size(0) {} 23029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf(uint32_t wi, uint32_t he, uint32_t f, uint32_t s) : 23129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w(wi), h(he), format(f), size(s) {} 23229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME not comparing size at the moment 23329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator==(const Whf& whf) const { 23429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return whf.w == w && whf.h == h && 23529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format == format; 23629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 23729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool operator!=(const Whf& whf) const { 23829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return !operator==(whf); 23929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 24029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 24129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t w; 24229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t h; 24329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t format; 24429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t size; 24529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 24629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 24756f610dd235b577725198e9341caae92379fdf23Saurabh Shahclass ActionSafe { 24856f610dd235b577725198e9341caae92379fdf23Saurabh Shahprivate: 24956f610dd235b577725198e9341caae92379fdf23Saurabh Shah ActionSafe() : mWidth(0.0f), mHeight(0.0f) { }; 25056f610dd235b577725198e9341caae92379fdf23Saurabh Shah float mWidth; 25156f610dd235b577725198e9341caae92379fdf23Saurabh Shah float mHeight; 25256f610dd235b577725198e9341caae92379fdf23Saurabh Shah static ActionSafe *sActionSafe; 25356f610dd235b577725198e9341caae92379fdf23Saurabh Shahpublic: 25456f610dd235b577725198e9341caae92379fdf23Saurabh Shah ~ActionSafe() { }; 25556f610dd235b577725198e9341caae92379fdf23Saurabh Shah static ActionSafe* getInstance() { 25656f610dd235b577725198e9341caae92379fdf23Saurabh Shah if(!sActionSafe) { 25756f610dd235b577725198e9341caae92379fdf23Saurabh Shah sActionSafe = new ActionSafe(); 25856f610dd235b577725198e9341caae92379fdf23Saurabh Shah } 25956f610dd235b577725198e9341caae92379fdf23Saurabh Shah return sActionSafe; 26056f610dd235b577725198e9341caae92379fdf23Saurabh Shah } 26156f610dd235b577725198e9341caae92379fdf23Saurabh Shah void setDimension(int w, int h) { 26256f610dd235b577725198e9341caae92379fdf23Saurabh Shah mWidth = (float)w; 26356f610dd235b577725198e9341caae92379fdf23Saurabh Shah mHeight = (float)h; 26456f610dd235b577725198e9341caae92379fdf23Saurabh Shah } 26556f610dd235b577725198e9341caae92379fdf23Saurabh Shah float getWidth() { return mWidth; } 26656f610dd235b577725198e9341caae92379fdf23Saurabh Shah float getHeight() { return mHeight; } 26756f610dd235b577725198e9341caae92379fdf23Saurabh Shah}; 26856f610dd235b577725198e9341caae92379fdf23Saurabh Shah 26929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { MAX_PATH_LEN = 256 }; 27029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 27129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/** 27229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Rotator flags: not to be confused with orientation flags. 27329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Ususally, you want to open the rotator to make sure it is 27429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ready for business. 275d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed * ROT_FLAG_DISABLED: Rotator not used unless required. 276d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed * ROT_FLAG_ENABLED: Rotator used even if not required. 27729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * */ 27829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eRotFlags { 27929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_FLAG_DISABLED = 0, 28029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_FLAG_ENABLED = 1 // needed in rot 28129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 28229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 28329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* The values for is_fg flag for control alpha and transp 28429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IS_FG_OFF means is_fg = 0 28529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IS_FG_SET means is_fg = 1 28629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed */ 28729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eIsFg { 28829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed IS_FG_OFF = 0, 28929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed IS_FG_SET = 1 29029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 29129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 29229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 29329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Various mdp flags like PIPE SHARE, DEINTERLACE etc... 29429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * kernel/common/linux/msm_mdp.h 29529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * INTERLACE_MASK: hardware/qcom/display/libgralloc/badger/fb_priv.h 29629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * */ 29729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eMdpFlags { 29829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_FLAGS_NONE = 0, 29929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_PIPE_SHARE = MDP_OV_PIPE_SHARE, 30029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_DEINTERLACE = MDP_DEINTERLACE, 301f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OV_MDP_SECURE_OVERLAY_SESSION = MDP_SECURE_OVERLAY_SESSION, 302f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OV_MDP_SOURCE_ROTATED_90 = MDP_SOURCE_ROTATED_90, 303f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OV_MDP_MEMORY_ID_TYPE_FB = MDP_MEMORY_ID_TYPE_FB, 304799a39759ba03b08cb96ffb4bb7a2359a2959d93Saurabh Shah OV_MDP_BACKEND_COMPOSITION = MDP_BACKEND_COMPOSITION, 30591a6a994e8d799ea2d4c4cbe6ff2e9be76105988Saurabh Shah OV_MDP_BLEND_FG_PREMULT = MDP_BLEND_FG_PREMULT, 306e87b66d295a83b90e22bf4b7c48051eaea01ef75Saurabh Shah OV_MDP_FLIP_H = MDP_FLIP_LR, 307e87b66d295a83b90e22bf4b7c48051eaea01ef75Saurabh Shah OV_MDP_FLIP_V = MDP_FLIP_UD, 3086457316fc7ae8ea29d763edce3fc1ffc78dd7387Saurabh Shah OV_MDSS_MDP_RIGHT_MIXER = MDSS_MDP_RIGHT_MIXER, 30929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 31029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 31129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eZorder { 31229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ZORDER_0, 31329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ZORDER_1, 31429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ZORDER_2, 315d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed ZORDER_3, 31629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Z_SYSTEM_ALLOC = 0xFFFF 31729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 31829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 31929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eMdpPipeType { 32029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OV_MDP_PIPE_RGB, 321d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_MDP_PIPE_VG, 322d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_MDP_PIPE_ANY, //Any 32329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 32429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 325d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed/* Used to identify destination pipes 326d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed */ 32729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eDest { 328d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG0 = 0, 329d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB0, 330d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG1, 331d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB1, 332d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_VG2, 333d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RGB2, 334d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_INVALID, 335d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed}; 336d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 337d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed/* Used when a buffer is split over 2 pipes and sent to display */ 338d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedenum { 339d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_LEFT_SPLIT = 0, 340d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed OV_RIGHT_SPLIT, 34129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 34229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 34329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* values for copybit_set_parameter(OVERLAY_TRANSFORM) */ 34429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eTransform { 34529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* No rot */ 346f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_0 = 0x0, 347f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* flip source image horizontally 0x1 */ 348f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, 349f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* flip source image vertically 0x2 */ 350f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, 35129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate source image 180 degrees 35229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * It is basically bit-or-ed H | V == 0x3 */ 353f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, 354f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees 0x4 */ 355f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, 356f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees and flip horizontally 0x5 */ 357f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90_FLIP_H = HAL_TRANSFORM_ROT_90 | 358f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed HAL_TRANSFORM_FLIP_H, 359f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed /* rotate source image 90 degrees and flip vertically 0x6 */ 360f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_90_FLIP_V = HAL_TRANSFORM_ROT_90 | 361f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed HAL_TRANSFORM_FLIP_V, 36229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate source image 270 degrees 36329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Basically 180 | 90 == 0x7 */ 364f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, 36529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* rotate invalid like in Transform.h */ 366f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed OVERLAY_TRANSFORM_INV = 0x80 36729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 36829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 36929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// Used to consolidate pipe params 37029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct PipeArgs { 37129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed PipeArgs() : mdpFlags(OV_MDP_FLAGS_NONE), 37229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed zorder(Z_SYSTEM_ALLOC), 37329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed isFg(IS_FG_OFF), 37429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed rotFlags(ROT_FLAG_DISABLED){ 37529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 37629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 377f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed PipeArgs(eMdpFlags f, Whf _whf, 37829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eZorder z, eIsFg fg, eRotFlags r) : 37929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mdpFlags(f), 38029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf(_whf), 38129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed zorder(z), 38229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed isFg(fg), 38329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed rotFlags(r) { 38429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 38529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 386f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed eMdpFlags mdpFlags; // for mdp_overlay flags 38729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Whf whf; 38829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eZorder zorder; // stage number 38929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eIsFg isFg; // control alpha & transp 39029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed eRotFlags rotFlags; 39129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 39229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 39329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void setMdpFlags(eMdpFlags& f, eMdpFlags v) { 39429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed f = static_cast<eMdpFlags>(setBit(f, v)); 39529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 39629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 39729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void clearMdpFlags(eMdpFlags& f, eMdpFlags v) { 39829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed f = static_cast<eMdpFlags>(clrBit(f, v)); 39929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 40029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 40129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// fb 0/1/2 40229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { FB0, FB1, FB2 }; 40329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 40429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//Panels could be categorized as primary and external 40529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { PRIMARY, EXTERNAL }; 40629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 40729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// 2 for rgb0/1 double bufs 40829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { RGB_PIPE_NUM_BUFS = 2 }; 40929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 41029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedstruct ScreenInfo { 41129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ScreenInfo() : mFBWidth(0), 41229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBHeight(0), 41329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBbpp(0), 41429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFBystride(0) {} 41529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump(const char* const s) const; 41629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBWidth; 41729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBHeight; 41829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBbpp; 41929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed uint32_t mFBystride; 42029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 42129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 42229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedint getMdpFormat(int format); 42329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedint getRotOutFmt(uint32_t format); 42429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* flip is upside down and such. V, H flip 42529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * rotation is 90, 180 etc 42629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * It returns MDP related enum/define that match rot+flip*/ 42729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedint getMdpOrient(eTransform rotation); 4289c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shahconst char* getFormatString(int format); 42929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 43029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// Cannot use HW_OVERLAY_MAGNIFICATION_LIMIT, since at the time 43129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// of integration, HW_OVERLAY_MAGNIFICATION_LIMIT was a define 43229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { HW_OV_MAGNIFICATION_LIMIT = 20, 43329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HW_OV_MINIFICATION_LIMIT = 8 43429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 43529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 43629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class T> 437f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline void memset0(T& t) { ::memset(&t, 0, sizeof(T)); } 43829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 43929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class T> inline void swap ( T& a, T& b ) 44029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 44129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed T c(a); a=b; b=c; 44229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 44329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 44429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int alignup(int value, int a) { 44529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed //if align = 0, return the value. Else, do alignment. 44629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return a ? ((((value - 1) / a) + 1) * a) : value; 44729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 44829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 44929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FIXME that align should replace the upper one. 45029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int align(int value, int a) { 45129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed //if align = 0, return the value. Else, do alignment. 45229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return a ? ((value + (a-1)) & ~(a-1)) : value; 45329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 45429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 45529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum eRotOutFmt { 45629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_OUT_FMT_DEFAULT, 45729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ROT_OUT_FMT_Y_CRCB_H2V2 45829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 45929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 46029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int ROT_OUT_FMT> struct RotOutFmt; 46129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 46229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FIXME, taken from gralloc_priv.h. Need to 46329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// put it back as soon as overlay takes place of the old one 46429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* possible formats for 3D content*/ 46529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { 46629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_NO_3D = 0x0000, 46729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, 46829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_TOP_BOTTOM = 0x20000, 46929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_INTERLEAVE = 0x40000, 47029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_IN_SIDE_BY_SIDE_R_L = 0x80000, 47129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_SIDE_BY_SIDE = 0x1000, 47229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOTTOM = 0x2000, 47329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERLEAVE = 0x4000, 47429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOSCOPIC = 0x8000 47529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 47629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 47729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedenum { HAL_3D_OUT_SBS_MASK = 47829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_SIDE_BY_SIDE >> overlay::utils::SHIFT_OUT_3D, 47929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOT_MASK = 48029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_TOP_BOTTOM >> overlay::utils::SHIFT_OUT_3D, 48129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERL_MASK = 48229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_INTERLEAVE >> overlay::utils::SHIFT_OUT_3D, 48329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOS_MASK = 48429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed HAL_3D_OUT_MONOSCOPIC >> overlay::utils::SHIFT_OUT_3D 48529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 48629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 48729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 48829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool isYuv(uint32_t format) { 48929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch(format){ 49029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V1: 49129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V2: 49229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CRCB_H2V2: 493b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CRCB_H1V1: 494b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CRCB_H2V1: 49529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CRCB_H2V2_TILE: 49629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V2_TILE: 497b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah case MDP_Y_CR_CB_H2V2: 498ae1044e0cbab8d26851782e85525ee9e0e6127e6Saurabh Shah case MDP_Y_CR_CB_GH2V2: 499d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan case MDP_Y_CBCR_H2V2_VENUS: 50029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 50129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 50229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 50329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 50429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 50529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 50629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 50729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool isRgb(uint32_t format) { 50829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch(format) { 50929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGBA_8888: 51029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_BGRA_8888: 51129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGBX_8888: 51229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_RGB_565: 51329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 51429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 51529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 51629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 51729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 51829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 51929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5209c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shahinline const char* getFormatString(int format){ 52129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const formats[] = { 52229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGB_565", 52329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_XRGB_8888", 52429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V2", 525f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H2V2_ADRENO", 52629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_ARGB_8888", 52729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGB_888", 52829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V2", 52929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_YCRYCB_H2V1", 53029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V1", 53129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V1", 532f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CRCB_H1V2", 533f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H1V2", 53429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGBA_8888", 53529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_BGRA_8888", 53629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_RGBX_8888", 53729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CRCB_H2V2_TILE", 53829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CBCR_H2V2_TILE", 53929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CR_CB_H2V2", 540f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CR_CB_GH2V2", 54129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_Y_CB_CR_H2V2", 542f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CRCB_H1V1", 543f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_Y_CBCR_H1V1", 544f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_YCRCB_H1V1", 545f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_YCBCR_H1V1", 54629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_BGR_565", 547d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan "MDP_BGR_888", 548d28fbcbdca035d5ca238aeba5628add89172c573Sushil Chauhan "MDP_Y_CBCR_H2V2_VENUS", 549f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_IMGTYPE_LIMIT", 550f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed "MDP_RGB_BORDERFILL", 55129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_FB_FORMAT", 55229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed "MDP_IMGTYPE_LIMIT2" 55329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed }; 5549c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah if(format < 0 || format >= (int)(sizeof(formats) / sizeof(formats[0]))) { 5559c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah ALOGE("%s wrong fmt %d", __FUNCTION__, format); 5569c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah return "Unsupported format"; 5579c876d9f8c446aaf01cf8dc3a2cd5cff48dc3585Saurabh Shah } 55829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return formats[format]; 55929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 56029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 56129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void Whf::dump() const { 56229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump WHF w=%d h=%d f=%d s=%d start/end ==", 56329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed w, h, format, size); 56429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 56529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 56629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void Dim::dump() const { 56729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump Dim x=%d y=%d w=%d h=%d start/end ==", x, y, w, h); 56829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 56929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 57029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int getMdpOrient(eTransform rotation) { 57129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, rotation); 572f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed switch(rotation) 57329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 57429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case OVERLAY_TRANSFORM_0 : return 0; 575f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_FLIP_V: return MDP_FLIP_UD; 576f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_FLIP_H: return MDP_FLIP_LR; 577f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_90: return MDP_ROT_90; 578a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah //getMdpOrient will switch the flips if the source is 90 rotated. 579a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah //Clients in Android dont factor in 90 rotation while deciding flip. 580f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_90_FLIP_V: 581f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed return MDP_ROT_90 | MDP_FLIP_LR; 582a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah case OVERLAY_TRANSFORM_ROT_90_FLIP_H: 583a73738dc7058df8821807b42a43c289e372136b8Saurabh Shah return MDP_ROT_90 | MDP_FLIP_UD; 584f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_180: return MDP_ROT_180; 585f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed case OVERLAY_TRANSFORM_ROT_270: return MDP_ROT_270; 58629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 587f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("%s: invalid rotation value (value = 0x%x", 588f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed __FUNCTION__, rotation); 58929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 59029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return -1; 59129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 59229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 59329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int getRotOutFmt(uint32_t format) { 59429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (format) { 59529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CRCB_H2V2_TILE: 59629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return MDP_Y_CRCB_H2V2; 59729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CBCR_H2V2_TILE: 59829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return MDP_Y_CBCR_H2V2; 59929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case MDP_Y_CB_CR_H2V2: 60029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return MDP_Y_CBCR_H2V2; 601ae1044e0cbab8d26851782e85525ee9e0e6127e6Saurabh Shah case MDP_Y_CR_CB_GH2V2: 602ae1044e0cbab8d26851782e85525ee9e0e6127e6Saurabh Shah return MDP_Y_CRCB_H2V2; 60329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 60429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return format; 60529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 60629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // not reached 60729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed OVASSERT(false, "%s not reached", __FUNCTION__); 60829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return -1; 60929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 61029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 61129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 61229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline uint32_t getColorFormat(uint32_t format) 61329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 614f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed return (format == HAL_PIXEL_FORMAT_YV12) ? 615f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed format : colorFormat(format); 61629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 61729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 61829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed// FB0 61929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 62029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline Dim getPositionS3DImpl(const Whf& whf) 62129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 62229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (whf.format & OUTPUT_3D_MASK) 62329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 62429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_SBS_MASK: 62529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // x, y, w, h 62629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w/2, whf.h); 62729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_TOP_BOT_MASK: 62829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w, whf.h/2); 62929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_MONOS_MASK: 63029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 63129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_INTERL_MASK: 63229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME error? 63329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_OUT_INTERLEAVE_MASK", __FUNCTION__); 63429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 63529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 63629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D output format %d", __FUNCTION__, 63729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format); 63829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 63929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 64029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 64129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 64229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <> 643d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline Dim getPositionS3DImpl<utils::OV_RIGHT_SPLIT>(const Whf& whf) 64429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 64529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (whf.format & OUTPUT_3D_MASK) 64629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 64729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_SBS_MASK: 64829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(whf.w/2, 0, whf.w/2, whf.h); 64929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_TOP_BOT_MASK: 65029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, whf.h/2, whf.w, whf.h/2); 65129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_MONOS_MASK: 65229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, whf.w, whf.h); 65329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_OUT_INTERL_MASK: 65429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME error? 65529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_OUT_INTERLEAVE_MASK", __FUNCTION__); 65629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 65729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 65829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D output format %d", __FUNCTION__, 65929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed whf.format); 66029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 66129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 66229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 66329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 66429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 66529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getPositionS3D(const Whf& whf, Dim& out) { 66629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed out = getPositionS3DImpl<CHAN>(whf); 66729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (out != Dim()); 66829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 66929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 67029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 67129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline Dim getCropS3DImpl(const Dim& in, uint32_t fmt) { 67229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (fmt & INPUT_3D_MASK) 67329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 67429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_L_R: 67529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w/2, in.h); 67629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_R_L: 67729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(in.w/2, 0, in.w/2, in.h); 67829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_TOP_BOTTOM: 67929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w, in.h/2); 68029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_INTERLEAVE: 68129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_IN_INTERLEAVE", __FUNCTION__); 68229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 68329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 68429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D format %d", __FUNCTION__, fmt); 68529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 68629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 68729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 68829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 68929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 69029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <> 691d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline Dim getCropS3DImpl<utils::OV_RIGHT_SPLIT>(const Dim& in, uint32_t fmt) { 69229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed switch (fmt & INPUT_3D_MASK) 69329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed { 69429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_L_R: 69529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(in.w/2, 0, in.w/2, in.h); 69629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_SIDE_BY_SIDE_R_L: 69729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, 0, in.w/2, in.h); 69829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_TOP_BOTTOM: 69929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(0, in.h/2, in.w, in.h/2); 70029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed case HAL_3D_IN_INTERLEAVE: 70129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s HAL_3D_IN_INTERLEAVE", __FUNCTION__); 70229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 70329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed default: 70429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s Unsupported 3D format %d", __FUNCTION__, fmt); 70529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed break; 70629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 70729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return Dim(); 70829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 70929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 71029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <int CHAN> 71129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getCropS3D(const Dim& in, Dim& out, uint32_t fmt) 71229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 71329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed out = getCropS3DImpl<CHAN>(in, fmt); 71429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (out != Dim()); 71529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 71629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 71729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedtemplate <class Type> 71829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid swapWidthHeight(Type& width, Type& height) { 71929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed Type tmp = width; 72029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed width = height; 72129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed height = tmp; 72229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 72329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 72429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void ScreenInfo::dump(const char* const s) const { 72529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump %s ScreenInfo w=%d h=%d" 72629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed " bpp=%d stride=%d start/end ==", 72729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, mFBWidth, mFBHeight, mFBbpp, mFBystride); 72829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 72929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 730e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shahinline bool openDev(OvFD& fd, int fbnum, 731e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah const char* const devpath, int flags) { 732e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah return overlay::open(fd, fbnum, devpath, flags); 733e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah} 734e012f7ad3026349c5a6edafbd550cd83655b99d5Saurabh Shah 735b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahtemplate <class T> 736b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahinline void even_ceil(T& value) { 737b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah if(value & 1) 738b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah value++; 739b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah} 740b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah 741b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahtemplate <class T> 742b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shahinline void even_floor(T& value) { 743b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah if(value & 1) 744b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah value--; 745b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah} 746b121e140e51d0dfcd4885289d56fb54b4d0d8e6eSaurabh Shah 747d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline const char* getDestStr(eDest dest) { 748d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed switch(dest) { 749d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG0: return "VG0"; 750d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB0: return "RGB0"; 751d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG1: return "VG1"; 752d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB1: return "RGB1"; 753d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG2: return "VG2"; 754d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB2: return "RGB2"; 755d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed default: return "Invalid"; 756d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed } 757d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return "Invalid"; 758d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed} 759d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 760d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline eMdpPipeType getPipeType(eDest dest) { 761d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed switch(dest) { 762d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG0: 763d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG1: 764d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_VG2: 765d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_VG; 766d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB0: 767d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB1: 768d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed case OV_RGB2: 769d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_RGB; 770d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed default: 771d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_ANY; 772d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed } 773d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed return OV_MDP_PIPE_ANY; 774d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed} 775d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed 77629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // namespace utils ends 77729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 77829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------------Class Res stuff (namespace overlay only) ----------- 77929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 78029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass Res { 78129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic: 78229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /dev/graphics/fb%u 783f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed static const char* const fbPath; 78429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /dev/msm_rotator 78529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const rotPath; 78629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/class/graphics/fb1/format_3d 78729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const format3DFile; 78829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/class/graphics/fb1/3d_present 78929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const edid3dInfoFile; 79029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // /sys/devices/platform/mipi_novatek.0/enable_3d_barrier 79129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed static const char* const barrierFile; 79229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 79329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------------Class OvFD stuff (namespace overlay only) ----------- 79629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 79829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Holds one FD 79929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Dtor will NOT close the underlying FD. 80029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* That enables us to copy that object around 80129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */ 80229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass OvFD { 80329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic: 80429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Ctor */ 80529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed explicit OvFD(); 80629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 80729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* dtor will NOT close the underlying FD */ 80829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ~OvFD(); 80929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 81029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Open fd using the path given by dev. 81129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * return false in failure */ 81229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool open(const char* const dev, 81329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int flags = O_RDWR); 81429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 81529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* populate path */ 81629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void setPath(const char* const dev); 81729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 81829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* Close fd if we have a valid fd. */ 81929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool close(); 82029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 82129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* returns underlying fd.*/ 82229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int getFD() const; 82329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 82429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* returns true if fd is valid */ 82529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed bool valid() const; 82629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 82729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* like operator= */ 82829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void copy(int fd); 82929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 83029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* dump the state of the instance */ 83129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed void dump() const; 83229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate: 83329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* helper enum for determine valid/invalid fd */ 83429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed enum { INVAL = -1 }; 83529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 83629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* actual os fd */ 83729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int mFD; 83829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 83929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed /* path, for debugging */ 84029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed char mPath[utils::MAX_PATH_LEN]; 84129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}; 84229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 84329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//-------------------Inlines-------------------------- 84429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 84529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool open(OvFD& fd, uint32_t fbnum, const char* const dev, int flags) 84629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 84729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed char dev_name[64] = {0}; 84829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed snprintf(dev_name, sizeof(dev_name), dev, fbnum); 84929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return fd.open(dev_name, flags); 85029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 85129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 85229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline OvFD::OvFD() : mFD (INVAL) { 85329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mPath[0] = 0; 85429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 85529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 856f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline OvFD::~OvFD() { 857f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed //no op since copy() can be used to share fd, in 3d cases. 858f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed} 85929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 86029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::open(const char* const dev, int flags) 86129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 86229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = ::open(dev, flags, 0); 86329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed if (mFD < 0) { 86429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed // FIXME errno, strerror in bionic? 86529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("Cant open device %s err=%d", dev, errno); 86629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 86729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 86829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed setPath(dev); 86929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 87029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 87129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 87229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::setPath(const char* const dev) 87329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 87429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ::strncpy(mPath, dev, utils::MAX_PATH_LEN); 87529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 87629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 87729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::close() 87829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 87929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed int ret = 0; 88029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed if(valid()) { 88129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ret = ::close(mFD); 88229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = INVAL; 88329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 88429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (ret == 0); 88529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 88629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 88729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool OvFD::valid() const 88829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 88929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return (mFD != INVAL); 89029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 89129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 89229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline int OvFD::getFD() const { return mFD; } 89329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 89429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::copy(int fd) { 89529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD = fd; 89629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 89729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 89829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void OvFD::dump() const 89929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed{ 90029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("== Dump OvFD fd=%d path=%s start/end ==", 90129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed mFD, mPath); 90229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 90329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 90429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//--------------- class OvFD stuff ends --------------------- 90529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 90629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // overlay 90729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 90829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 90929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // OVERLAY_UTILS_H 910