| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* | 
| Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 3 | * | 
 | 4 | * Redistribution and use in source and binary forms, with or without | 
 | 5 | * modification, are permitted provided that the following conditions are | 
 | 6 | * met: | 
 | 7 | *    * Redistributions of source code must retain the above copyright | 
 | 8 | *      notice, this list of conditions and the following disclaimer. | 
 | 9 | *    * Redistributions in binary form must reproduce the above | 
 | 10 | *      copyright notice, this list of conditions and the following | 
 | 11 | *      disclaimer in the documentation and/or other materials provided | 
 | 12 | *      with the distribution. | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 13 | *    * Neither the name of The Linux Foundation. nor the names of its | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 14 | *      contributors may be used to endorse or promote products derived | 
 | 15 | *      from this software without specific prior written permission. | 
 | 16 | * | 
 | 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | 
 | 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 
 | 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | 
 | 20 | * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | 
 | 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
 | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
 | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | 
 | 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 
 | 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | 
 | 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | 
 | 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
 | 28 | */ | 
 | 29 |  | 
 | 30 | #ifndef OVERLAY_H | 
 | 31 | #define OVERLAY_H | 
 | 32 |  | 
 | 33 | #include "overlayUtils.h" | 
| Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 34 | #include "mdp_version.h" | 
| Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 35 | #include "utils/threads.h" | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 36 |  | 
| Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 37 | struct MetaData_t; | 
 | 38 |  | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 39 | namespace overlay { | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 40 | class GenericPipe; | 
 | 41 |  | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 42 | class Overlay : utils::NoCopy { | 
 | 43 | public: | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 44 |     enum { DMA_BLOCK_MODE, DMA_LINE_MODE }; | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 45 |     //Abstract Display types. Each backed by a LayerMixer, | 
 | 46 |     //represented by a fb node. | 
 | 47 |     //High res panels can be backed by 2 layer mixers and a single fb node. | 
 | 48 |     enum { DPY_PRIMARY, DPY_EXTERNAL, DPY_WRITEBACK, DPY_UNUSED }; | 
 | 49 |     enum { DPY_MAX = DPY_UNUSED }; | 
| Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 50 |     enum { MIXER_LEFT, MIXER_RIGHT, MIXER_UNUSED }; | 
 | 51 |     enum { MIXER_DEFAULT = MIXER_LEFT, MIXER_MAX = MIXER_UNUSED }; | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 52 |     enum { MAX_FB_DEVICES = DPY_MAX }; | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 53 |     enum { FORMAT_YUV, FORMAT_RGB }; | 
 | 54 |  | 
 | 55 |     struct PipeSpecs { | 
 | 56 |         PipeSpecs() : formatClass(FORMAT_RGB), needsScaling(false), fb(false), | 
| Xu Yang | 1e686f6 | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 57 |                 dpy(DPY_PRIMARY), mixer(MIXER_DEFAULT), numActiveDisplays(1) {} | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 58 |         int formatClass; | 
 | 59 |         bool needsScaling; | 
 | 60 |         bool fb; | 
 | 61 |         int dpy; | 
 | 62 |         int mixer; | 
| Xu Yang | 1e686f6 | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 63 |         int numActiveDisplays; | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 64 |     }; | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 65 |  | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 66 |     /* dtor close */ | 
 | 67 |     ~Overlay(); | 
 | 68 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 69 |     /* Marks the beginning of a drawing round, resets usage bits on pipes | 
 | 70 |      * Should be called when drawing begins before any pipe config is done. | 
 | 71 |      */ | 
 | 72 |     void configBegin(); | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 73 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 74 |     /* Marks the end of config for this drawing round | 
 | 75 |      * Will do garbage collection of pipe objects and thus calling UNSETs, | 
 | 76 |      * closing FDs, removing rotator objects and memory, if allocated. | 
 | 77 |      * Should be called after all pipe configs are done. | 
 | 78 |      */ | 
 | 79 |     void configDone(); | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 80 |  | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 81 |     /* Get a pipe that supported the specified format class (yuv, rgb) and has | 
 | 82 |      * scaling capabilities. | 
 | 83 |      */ | 
 | 84 |     utils::eDest getPipe(const PipeSpecs& pipeSpecs); | 
| Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 85 |     /* Returns the eDest corresponding to an already allocated pipeid. | 
 | 86 |      * Useful for the reservation case, when libvpu reserves the pipe at its | 
 | 87 |      * end, and expect the overlay to allocate a given pipe for a layer. | 
 | 88 |      */ | 
 | 89 |     utils::eDest reservePipe(int pipeid); | 
 | 90 |     /* getting dest for the given pipeid */ | 
 | 91 |     utils::eDest getDest(int pipeid); | 
 | 92 |     /* getting overlay.pipeid for the given dest */ | 
 | 93 |     int getPipeId(utils::eDest dest); | 
| Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 94 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 95 |     void setSource(const utils::PipeArgs args, utils::eDest dest); | 
 | 96 |     void setCrop(const utils::Dim& d, utils::eDest dest); | 
| Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 97 |     void setColor(const uint32_t color, utils::eDest dest); | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 98 |     void setTransform(const int orientation, utils::eDest dest); | 
 | 99 |     void setPosition(const utils::Dim& dim, utils::eDest dest); | 
| Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 100 |     void setVisualParams(const MetaData_t& data, utils::eDest dest); | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 101 |     bool commit(utils::eDest dest); | 
 | 102 |     bool queueBuffer(int fd, uint32_t offset, utils::eDest dest); | 
| Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 103 |  | 
| Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 104 |     /* pipe reservation session is running */ | 
 | 105 |     bool sessionInProgress(utils::eDest dest); | 
 | 106 |     /* pipe reservation session has ended*/ | 
 | 107 |     bool isSessionEnded(utils::eDest dest); | 
 | 108 |     /* start session for the pipe reservation */ | 
 | 109 |     void startSession(utils::eDest dest); | 
 | 110 |     /* end all started sesisons */ | 
 | 111 |     void endAllSessions(); | 
| Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 112 |     /* Returns available ("unallocated") pipes for a display's mixer */ | 
 | 113 |     int availablePipes(int dpy, int mixer); | 
| Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 114 |     /* Returns available ("unallocated") pipes for a display */ | 
 | 115 |     int availablePipes(int dpy); | 
| Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 116 |     /* Returns available ("unallocated") pipe of given type for a display */ | 
 | 117 |     int availablePipes(int dpy, utils::eMdpPipeType type); | 
| Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 118 |     /* Returns if any of the requested pipe type is attached to any of the | 
 | 119 |      * displays | 
 | 120 |      */ | 
 | 121 |     bool isPipeTypeAttached(utils::eMdpPipeType type); | 
| Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 122 |     /* Compare pipe priorities and return | 
 | 123 |      * 1 if 1st pipe has a higher priority | 
 | 124 |      * 0 if both have the same priority | 
 | 125 |      *-1 if 2nd pipe has a higher priority | 
 | 126 |      */ | 
 | 127 |     int comparePipePriority(utils::eDest pipe1Index, utils::eDest pipe2Index); | 
| Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 128 |     /* Returns pipe dump. Expects a NULL terminated buffer of big enough size | 
 | 129 |      * to populate. | 
 | 130 |      */ | 
| Raj Kamal | 068f457 | 2014-04-14 16:14:06 +0530 | [diff] [blame] | 131 |     /* Returns if DMA pipe multiplexing is supported by the mdss driver */ | 
 | 132 |     static bool isDMAMultiplexingSupported(); | 
 | 133 |     /* Returns if UI scaling on external is supported on the targets */ | 
 | 134 |     static bool isUIScalingOnExternalSupported(); | 
| Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 135 |     void getDump(char *buf, size_t len); | 
| Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 136 |     /* Reset usage and allocation bits on all pipes for given display */ | 
 | 137 |     void clear(int dpy); | 
| Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 138 |     /* Validate the set of pipes for a display and set them in driver */ | 
 | 139 |     bool validateAndSet(const int& dpy, const int& fbFd); | 
| Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame] | 140 |  | 
 | 141 |     /* Closes open pipes, called during startup */ | 
 | 142 |     static int initOverlay(); | 
 | 143 |     /* Returns the singleton instance of overlay */ | 
 | 144 |     static Overlay* getInstance(); | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 145 |     static void setDMAMode(const int& mode); | 
 | 146 |     static int getDMAMode(); | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 147 |     /* Returns the framebuffer node backing up the display */ | 
 | 148 |     static int getFbForDpy(const int& dpy); | 
| Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 149 |  | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 150 |     static bool displayCommit(const int& fd); | 
| Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 151 |     /* Overloads display commit with ROI's of each halves. | 
 | 152 |      * Single interface panels will only update left ROI. */ | 
 | 153 |     static bool displayCommit(const int& fd, const utils::Dim& lRoi, | 
 | 154 |                               const utils::Dim& rRoi); | 
| Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 155 |     /* Logs pipe lifecycle events like set, unset, commit when enabled */ | 
 | 156 |     static void debugPipeLifecycle(const bool& enable); | 
 | 157 |     /* Returns true if pipe life cycle logging is enabled */ | 
 | 158 |     static bool isDebugPipeLifecycle(); | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 159 |  | 
 | 160 | private: | 
 | 161 |     /* Ctor setup */ | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 162 |     explicit Overlay(); | 
 | 163 |     /*Validate index range, abort if invalid */ | 
 | 164 |     void validate(int index); | 
| Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 165 |     static void setDMAMultiplexingSupported(); | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 166 |     /* Returns an available pipe based on the type of pipe requested. When ANY | 
 | 167 |      * is requested, the first available VG or RGB is returned. If no pipe is | 
 | 168 |      * available for the display "dpy" then INV is returned. Note: If a pipe is | 
 | 169 |      * assigned to a certain display, then it cannot be assigned to another | 
 | 170 |      * display without being garbage-collected once. To add if a pipe is | 
 | 171 |      * asisgned to a mixer within a display it cannot be reused for another | 
 | 172 |      * mixer without being UNSET once*/ | 
 | 173 |     utils::eDest nextPipe(utils::eMdpPipeType, int dpy, int mixer); | 
 | 174 |     /* Helpers that enfore target specific policies while returning pipes */ | 
 | 175 |     utils::eDest getPipe_8x26(const PipeSpecs& pipeSpecs); | 
 | 176 |     utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs); | 
| Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 177 |     utils::eDest getPipe_8x39(const PipeSpecs& pipeSpecs); | 
| Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 178 |     utils::eDest getPipe_8994(const PipeSpecs& pipeSpecs); | 
| Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 179 |  | 
| Saurabh Shah | eac146b | 2014-05-13 11:36:20 -0700 | [diff] [blame] | 180 |     /* Returns the handle to libscale.so's programScale function */ | 
 | 181 |     static int (*getFnProgramScale())(struct mdp_overlay_list *); | 
| Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 182 |     /* Creates a scalar object using libscale.so */ | 
 | 183 |     static void initScalar(); | 
 | 184 |     /* Destroys the scalar object using libscale.so */ | 
 | 185 |     static void destroyScalar(); | 
| radhakrishna | 8ccb908 | 2014-05-09 16:18:43 +0530 | [diff] [blame] | 186 |     /* Sets the pipe type RGB/VG/DMA*/ | 
 | 187 |     void setPipeType(utils::eDest pipeIndex, const utils::eMdpPipeType pType); | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 188 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 189 |     /* Just like a Facebook for pipes, but much less profile info */ | 
 | 190 |     struct PipeBook { | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 191 |         void init(); | 
 | 192 |         void destroy(); | 
 | 193 |         /* Check if pipe exists and return true, false otherwise */ | 
 | 194 |         bool valid(); | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 195 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 196 |         /* Hardware pipe wrapper */ | 
 | 197 |         GenericPipe *mPipe; | 
 | 198 |         /* Display using this pipe. Refer to enums above */ | 
 | 199 |         int mDisplay; | 
| Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 200 |         /* Mixer within a split display this pipe is attached to */ | 
 | 201 |         int mMixer; | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 202 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 203 |         /* operations on bitmap */ | 
 | 204 |         static bool pipeUsageUnchanged(); | 
 | 205 |         static void setUse(int index); | 
 | 206 |         static void resetUse(int index); | 
 | 207 |         static bool isUsed(int index); | 
 | 208 |         static bool isNotUsed(int index); | 
 | 209 |         static void save(); | 
 | 210 |  | 
 | 211 |         static void setAllocation(int index); | 
 | 212 |         static void resetAllocation(int index); | 
 | 213 |         static bool isAllocated(int index); | 
 | 214 |         static bool isNotAllocated(int index); | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 215 |  | 
| Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 216 |         static utils::eMdpPipeType getPipeType(utils::eDest dest); | 
 | 217 |         static const char* getDestStr(utils::eDest dest); | 
 | 218 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 219 |         static int NUM_PIPES; | 
| Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 220 |         static utils::eMdpPipeType pipeTypeLUT[utils::OV_MAX]; | 
| Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 221 |         /* Session for reserved pipes */ | 
 | 222 |         enum Session { | 
 | 223 |             NONE, | 
 | 224 |             START, | 
 | 225 |             END | 
 | 226 |         }; | 
 | 227 |         Session mSession; | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 228 |  | 
 | 229 |     private: | 
 | 230 |         //usage tracks if a successful commit happened. So a pipe could be | 
 | 231 |         //allocated to a display, but it may not end up using it for various | 
 | 232 |         //reasons. If one display actually uses a pipe then it amy not be | 
 | 233 |         //used by another display, without an UNSET in between. | 
 | 234 |         static int sPipeUsageBitmap; | 
 | 235 |         static int sLastUsageBitmap; | 
 | 236 |         //Tracks which pipe objects are allocated. This does not imply that they | 
 | 237 |         //will actually be used. For example, a display might choose to acquire | 
 | 238 |         //3 pipe objects in one shot and proceed with config only if it gets all | 
 | 239 |         //3. The bitmap helps allocate different pipe objects on each request. | 
 | 240 |         static int sAllocatedBitmap; | 
 | 241 |     }; | 
 | 242 |  | 
 | 243 |     PipeBook mPipeBook[utils::OV_INVALID]; //Used as max | 
 | 244 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 245 |     /* Singleton Instance*/ | 
 | 246 |     static Overlay *sInstance; | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 247 |     static int sDpyFbMap[DPY_MAX]; | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 248 |     static int sDMAMode; | 
| Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 249 |     static bool sDMAMultiplexingSupported; | 
| Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 250 |     static void *sLibScaleHandle; | 
| Saurabh Shah | eac146b | 2014-05-13 11:36:20 -0700 | [diff] [blame] | 251 |     static int (*sFnProgramScale)(struct mdp_overlay_list *); | 
| Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 252 |     static bool sDebugPipeLifecycle; | 
| Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 253 |  | 
 | 254 |     friend class MdpCtrl; | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 255 | }; | 
 | 256 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 257 | inline void Overlay::validate(int index) { | 
 | 258 |     OVASSERT(index >=0 && index < PipeBook::NUM_PIPES, \ | 
 | 259 |         "%s, Index out of bounds: %d", __FUNCTION__, index); | 
 | 260 |     OVASSERT(mPipeBook[index].valid(), "Pipe does not exist %s", | 
| Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 261 |             PipeBook::getDestStr((utils::eDest)index)); | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 262 | } | 
 | 263 |  | 
| Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 264 | inline int Overlay::availablePipes(int dpy, int mixer) { | 
 | 265 |     int avail = 0; | 
 | 266 |     for(int i = 0; i < PipeBook::NUM_PIPES; i++) { | 
 | 267 |         if( (mPipeBook[i].mDisplay == DPY_UNUSED || | 
 | 268 |              mPipeBook[i].mDisplay == dpy) && | 
 | 269 |             (mPipeBook[i].mMixer == MIXER_UNUSED || | 
 | 270 |              mPipeBook[i].mMixer == mixer) && | 
 | 271 |             PipeBook::isNotAllocated(i) && | 
 | 272 |             !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE && | 
 | 273 |               PipeBook::getPipeType((utils::eDest)i) == | 
 | 274 |               utils::OV_MDP_PIPE_DMA)) { | 
 | 275 |             avail++; | 
| Jeykumar Sankaran | ccb4460 | 2013-01-03 12:48:22 -0800 | [diff] [blame] | 276 |         } | 
 | 277 |     } | 
 | 278 |     return avail; | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 279 | } | 
 | 280 |  | 
| Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 281 | inline int Overlay::availablePipes(int dpy) { | 
 | 282 |     int avail = 0; | 
 | 283 |     for(int i = 0; i < PipeBook::NUM_PIPES; i++) { | 
 | 284 |         if( (mPipeBook[i].mDisplay == DPY_UNUSED || | 
 | 285 |              mPipeBook[i].mDisplay == dpy) && | 
 | 286 |             PipeBook::isNotAllocated(i) && | 
 | 287 |             !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE && | 
 | 288 |               PipeBook::getPipeType((utils::eDest)i) == | 
 | 289 |               utils::OV_MDP_PIPE_DMA)) { | 
 | 290 |             avail++; | 
 | 291 |         } | 
 | 292 |     } | 
 | 293 |     return avail; | 
 | 294 | } | 
 | 295 |  | 
| Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 296 | inline int Overlay::availablePipes(int dpy, utils::eMdpPipeType type) { | 
 | 297 |     int avail = 0; | 
 | 298 |     for(int i = 0; i < PipeBook::NUM_PIPES; i++) { | 
 | 299 |         if((mPipeBook[i].mDisplay == DPY_UNUSED || | 
 | 300 |             mPipeBook[i].mDisplay == dpy) && | 
 | 301 |             PipeBook::isNotAllocated(i) && | 
 | 302 |             type == PipeBook::getPipeType((utils::eDest)i)) { | 
 | 303 |             avail++; | 
 | 304 |         } | 
 | 305 |     } | 
 | 306 |     return avail; | 
 | 307 | } | 
 | 308 |  | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 309 | inline void Overlay::setDMAMode(const int& mode) { | 
 | 310 |     if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE) | 
 | 311 |         sDMAMode = mode; | 
 | 312 | } | 
 | 313 |  | 
| Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 314 | inline void Overlay::setDMAMultiplexingSupported() { | 
 | 315 |     sDMAMultiplexingSupported = false; | 
 | 316 |     if(qdutils::MDPVersion::getInstance().is8x26()) | 
 | 317 |         sDMAMultiplexingSupported = true; | 
 | 318 | } | 
 | 319 |  | 
| Raj Kamal | 068f457 | 2014-04-14 16:14:06 +0530 | [diff] [blame] | 320 | inline bool Overlay::isDMAMultiplexingSupported() { | 
 | 321 |     return sDMAMultiplexingSupported; | 
 | 322 | } | 
 | 323 |  | 
 | 324 | inline bool Overlay::isUIScalingOnExternalSupported() { | 
 | 325 |     if(qdutils::MDPVersion::getInstance().is8x26() or | 
| Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 326 |        qdutils::MDPVersion::getInstance().is8x16() or | 
 | 327 |        qdutils::MDPVersion::getInstance().is8x39()) { | 
| Raj Kamal | 068f457 | 2014-04-14 16:14:06 +0530 | [diff] [blame] | 328 |         return false; | 
 | 329 |     } | 
 | 330 |     return true; | 
 | 331 | } | 
 | 332 |  | 
| Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 333 | inline int Overlay::getDMAMode() { | 
 | 334 |     return sDMAMode; | 
 | 335 | } | 
 | 336 |  | 
| Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 337 | inline int Overlay::getFbForDpy(const int& dpy) { | 
 | 338 |     OVASSERT(dpy >= 0 && dpy < DPY_MAX, "Invalid dpy %d", dpy); | 
 | 339 |     return sDpyFbMap[dpy]; | 
 | 340 | } | 
 | 341 |  | 
| Saurabh Shah | eac146b | 2014-05-13 11:36:20 -0700 | [diff] [blame] | 342 | inline int (*Overlay::getFnProgramScale())(struct mdp_overlay_list *) { | 
 | 343 |     return sFnProgramScale; | 
| Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 344 | } | 
 | 345 |  | 
| Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 346 | inline void Overlay::debugPipeLifecycle(const bool& enable) { | 
 | 347 |     sDebugPipeLifecycle = enable; | 
 | 348 | } | 
 | 349 |  | 
 | 350 | inline bool Overlay::isDebugPipeLifecycle() { | 
 | 351 |     return sDebugPipeLifecycle; | 
 | 352 | } | 
 | 353 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 354 | inline bool Overlay::PipeBook::valid() { | 
 | 355 |     return (mPipe != NULL); | 
 | 356 | } | 
 | 357 |  | 
 | 358 | inline bool Overlay::PipeBook::pipeUsageUnchanged() { | 
 | 359 |     return (sPipeUsageBitmap == sLastUsageBitmap); | 
 | 360 | } | 
 | 361 |  | 
 | 362 | inline void Overlay::PipeBook::setUse(int index) { | 
 | 363 |     sPipeUsageBitmap |= (1 << index); | 
 | 364 | } | 
 | 365 |  | 
 | 366 | inline void Overlay::PipeBook::resetUse(int index) { | 
 | 367 |     sPipeUsageBitmap &= ~(1 << index); | 
 | 368 | } | 
 | 369 |  | 
 | 370 | inline bool Overlay::PipeBook::isUsed(int index) { | 
 | 371 |     return sPipeUsageBitmap & (1 << index); | 
 | 372 | } | 
 | 373 |  | 
 | 374 | inline bool Overlay::PipeBook::isNotUsed(int index) { | 
 | 375 |     return !isUsed(index); | 
 | 376 | } | 
 | 377 |  | 
 | 378 | inline void Overlay::PipeBook::save() { | 
 | 379 |     sLastUsageBitmap = sPipeUsageBitmap; | 
 | 380 | } | 
 | 381 |  | 
 | 382 | inline void Overlay::PipeBook::setAllocation(int index) { | 
 | 383 |     sAllocatedBitmap |= (1 << index); | 
 | 384 | } | 
 | 385 |  | 
 | 386 | inline void Overlay::PipeBook::resetAllocation(int index) { | 
 | 387 |     sAllocatedBitmap &= ~(1 << index); | 
 | 388 | } | 
 | 389 |  | 
 | 390 | inline bool Overlay::PipeBook::isAllocated(int index) { | 
 | 391 |     return sAllocatedBitmap & (1 << index); | 
 | 392 | } | 
 | 393 |  | 
 | 394 | inline bool Overlay::PipeBook::isNotAllocated(int index) { | 
 | 395 |     return !isAllocated(index); | 
 | 396 | } | 
 | 397 |  | 
| Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 398 | inline utils::eMdpPipeType Overlay::PipeBook::getPipeType(utils::eDest dest) { | 
 | 399 |     return pipeTypeLUT[(int)dest]; | 
 | 400 | } | 
 | 401 |  | 
| Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 402 | inline void Overlay::startSession(utils::eDest dest) { | 
 | 403 |     mPipeBook[(int)dest].mSession = PipeBook::START; | 
 | 404 | } | 
 | 405 |  | 
 | 406 | inline bool Overlay::sessionInProgress(utils::eDest dest) { | 
 | 407 |     return (mPipeBook[(int)dest].mSession == PipeBook::START); | 
 | 408 | } | 
 | 409 |  | 
 | 410 | inline bool Overlay::isSessionEnded(utils::eDest dest) { | 
 | 411 |     return (mPipeBook[(int)dest].mSession == PipeBook::END); | 
 | 412 | } | 
 | 413 |  | 
| Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 414 | inline const char* Overlay::PipeBook::getDestStr(utils::eDest dest) { | 
 | 415 |     switch(getPipeType(dest)) { | 
 | 416 |         case utils::OV_MDP_PIPE_RGB: return "RGB"; | 
 | 417 |         case utils::OV_MDP_PIPE_VG: return "VG"; | 
 | 418 |         case utils::OV_MDP_PIPE_DMA: return "DMA"; | 
 | 419 |         default: return "Invalid"; | 
 | 420 |     } | 
 | 421 |     return "Invalid"; | 
 | 422 | } | 
 | 423 |  | 
| Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 424 | }; // overlay | 
| Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 425 |  | 
 | 426 | #endif // OVERLAY_H |