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" |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 34 | #include "utils/threads.h" |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 35 | |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 36 | struct MetaData_t; |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 37 | namespace scale { |
| 38 | class Scale; |
| 39 | }; |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 40 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 41 | namespace overlay { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 42 | class GenericPipe; |
| 43 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 44 | class Overlay : utils::NoCopy { |
| 45 | public: |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 46 | enum { DMA_BLOCK_MODE, DMA_LINE_MODE }; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 47 | //Abstract Display types. Each backed by a LayerMixer, |
| 48 | //represented by a fb node. |
| 49 | //High res panels can be backed by 2 layer mixers and a single fb node. |
| 50 | enum { DPY_PRIMARY, DPY_EXTERNAL, DPY_WRITEBACK, DPY_UNUSED }; |
| 51 | enum { DPY_MAX = DPY_UNUSED }; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 52 | enum { MIXER_LEFT, MIXER_RIGHT, MIXER_UNUSED }; |
| 53 | enum { MIXER_DEFAULT = MIXER_LEFT, MIXER_MAX = MIXER_UNUSED }; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 54 | enum { MAX_FB_DEVICES = DPY_MAX }; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 55 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 56 | /* dtor close */ |
| 57 | ~Overlay(); |
| 58 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 59 | /* Marks the beginning of a drawing round, resets usage bits on pipes |
| 60 | * Should be called when drawing begins before any pipe config is done. |
| 61 | */ |
| 62 | void configBegin(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 63 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 64 | /* Marks the end of config for this drawing round |
| 65 | * Will do garbage collection of pipe objects and thus calling UNSETs, |
| 66 | * closing FDs, removing rotator objects and memory, if allocated. |
| 67 | * Should be called after all pipe configs are done. |
| 68 | */ |
| 69 | void configDone(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 70 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 71 | /* Returns an available pipe based on the type of pipe requested. When ANY |
| 72 | * is requested, the first available VG or RGB is returned. If no pipe is |
| 73 | * available for the display "dpy" then INV is returned. Note: If a pipe is |
| 74 | * assigned to a certain display, then it cannot be assigned to another |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 75 | * display without being garbage-collected once. To add if a pipe is |
| 76 | * asisgned to a mixer within a display it cannot be reused for another |
| 77 | * mixer without being UNSET once*/ |
| 78 | utils::eDest nextPipe(utils::eMdpPipeType, int dpy, int mixer); |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame^] | 79 | /* Returns the eDest corresponding to an already allocated pipeid. |
| 80 | * Useful for the reservation case, when libvpu reserves the pipe at its |
| 81 | * end, and expect the overlay to allocate a given pipe for a layer. |
| 82 | */ |
| 83 | utils::eDest reservePipe(int pipeid); |
| 84 | /* getting dest for the given pipeid */ |
| 85 | utils::eDest getDest(int pipeid); |
| 86 | /* getting overlay.pipeid for the given dest */ |
| 87 | int getPipeId(utils::eDest dest); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 88 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 89 | void setSource(const utils::PipeArgs args, utils::eDest dest); |
| 90 | void setCrop(const utils::Dim& d, utils::eDest dest); |
| 91 | void setTransform(const int orientation, utils::eDest dest); |
| 92 | void setPosition(const utils::Dim& dim, utils::eDest dest); |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 93 | void setVisualParams(const MetaData_t& data, utils::eDest dest); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 94 | bool commit(utils::eDest dest); |
| 95 | bool queueBuffer(int fd, uint32_t offset, utils::eDest dest); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 96 | |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame^] | 97 | /* pipe reservation session is running */ |
| 98 | bool sessionInProgress(utils::eDest dest); |
| 99 | /* pipe reservation session has ended*/ |
| 100 | bool isSessionEnded(utils::eDest dest); |
| 101 | /* start session for the pipe reservation */ |
| 102 | void startSession(utils::eDest dest); |
| 103 | /* end all started sesisons */ |
| 104 | void endAllSessions(); |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 105 | /* Returns available ("unallocated") pipes for a display's mixer */ |
| 106 | int availablePipes(int dpy, int mixer); |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 107 | /* Returns available ("unallocated") pipes for a display */ |
| 108 | int availablePipes(int dpy); |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 109 | /* Returns available ("unallocated") pipe of given type for a display */ |
| 110 | int availablePipes(int dpy, utils::eMdpPipeType type); |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 111 | /* Returns if any of the requested pipe type is attached to any of the |
| 112 | * displays |
| 113 | */ |
| 114 | bool isPipeTypeAttached(utils::eMdpPipeType type); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 115 | /* Returns pipe dump. Expects a NULL terminated buffer of big enough size |
| 116 | * to populate. |
| 117 | */ |
| 118 | void getDump(char *buf, size_t len); |
Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 119 | /* Reset usage and allocation bits on all pipes for given display */ |
| 120 | void clear(int dpy); |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame] | 121 | /* Marks the display, whose pipes need to be forcibaly configured */ |
| 122 | void forceSet(const int& dpy); |
| 123 | |
| 124 | /* Closes open pipes, called during startup */ |
| 125 | static int initOverlay(); |
| 126 | /* Returns the singleton instance of overlay */ |
| 127 | static Overlay* getInstance(); |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 128 | static void setDMAMode(const int& mode); |
| 129 | static int getDMAMode(); |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 130 | /* Returns the framebuffer node backing up the display */ |
| 131 | static int getFbForDpy(const int& dpy); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 132 | static bool displayCommit(const int& fd, const utils::Dim& roi); |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 133 | static bool displayCommit(const int& fd); |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 134 | /* Returns the scalar object */ |
| 135 | static scale::Scale *getScalar(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 136 | |
| 137 | private: |
| 138 | /* Ctor setup */ |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 139 | explicit Overlay(); |
| 140 | /*Validate index range, abort if invalid */ |
| 141 | void validate(int index); |
| 142 | void dump() const; |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 143 | /* Creates a scalar object using libscale.so */ |
| 144 | static void initScalar(); |
| 145 | /* Destroys the scalar object using libscale.so */ |
| 146 | static void destroyScalar(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 147 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 148 | /* Just like a Facebook for pipes, but much less profile info */ |
| 149 | struct PipeBook { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 150 | void init(); |
| 151 | void destroy(); |
| 152 | /* Check if pipe exists and return true, false otherwise */ |
| 153 | bool valid(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 154 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 155 | /* Hardware pipe wrapper */ |
| 156 | GenericPipe *mPipe; |
| 157 | /* Display using this pipe. Refer to enums above */ |
| 158 | int mDisplay; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 159 | /* Mixer within a split display this pipe is attached to */ |
| 160 | int mMixer; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 161 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 162 | /* operations on bitmap */ |
| 163 | static bool pipeUsageUnchanged(); |
| 164 | static void setUse(int index); |
| 165 | static void resetUse(int index); |
| 166 | static bool isUsed(int index); |
| 167 | static bool isNotUsed(int index); |
| 168 | static void save(); |
| 169 | |
| 170 | static void setAllocation(int index); |
| 171 | static void resetAllocation(int index); |
| 172 | static bool isAllocated(int index); |
| 173 | static bool isNotAllocated(int index); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 174 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 175 | static utils::eMdpPipeType getPipeType(utils::eDest dest); |
| 176 | static const char* getDestStr(utils::eDest dest); |
| 177 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 178 | static int NUM_PIPES; |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 179 | static utils::eMdpPipeType pipeTypeLUT[utils::OV_MAX]; |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame^] | 180 | /* Session for reserved pipes */ |
| 181 | enum Session { |
| 182 | NONE, |
| 183 | START, |
| 184 | END |
| 185 | }; |
| 186 | Session mSession; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 187 | |
| 188 | private: |
| 189 | //usage tracks if a successful commit happened. So a pipe could be |
| 190 | //allocated to a display, but it may not end up using it for various |
| 191 | //reasons. If one display actually uses a pipe then it amy not be |
| 192 | //used by another display, without an UNSET in between. |
| 193 | static int sPipeUsageBitmap; |
| 194 | static int sLastUsageBitmap; |
| 195 | //Tracks which pipe objects are allocated. This does not imply that they |
| 196 | //will actually be used. For example, a display might choose to acquire |
| 197 | //3 pipe objects in one shot and proceed with config only if it gets all |
| 198 | //3. The bitmap helps allocate different pipe objects on each request. |
| 199 | static int sAllocatedBitmap; |
| 200 | }; |
| 201 | |
| 202 | PipeBook mPipeBook[utils::OV_INVALID]; //Used as max |
| 203 | |
| 204 | /* Dump string */ |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 205 | char mDumpStr[1024]; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 206 | |
| 207 | /* Singleton Instance*/ |
| 208 | static Overlay *sInstance; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 209 | static int sDpyFbMap[DPY_MAX]; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 210 | static int sDMAMode; |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame] | 211 | static int sForceSetBitmap; |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 212 | static void *sLibScaleHandle; |
| 213 | static scale::Scale *sScale; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 214 | }; |
| 215 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 216 | inline void Overlay::validate(int index) { |
| 217 | OVASSERT(index >=0 && index < PipeBook::NUM_PIPES, \ |
| 218 | "%s, Index out of bounds: %d", __FUNCTION__, index); |
| 219 | OVASSERT(mPipeBook[index].valid(), "Pipe does not exist %s", |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 220 | PipeBook::getDestStr((utils::eDest)index)); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 221 | } |
| 222 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 223 | inline int Overlay::availablePipes(int dpy, int mixer) { |
| 224 | int avail = 0; |
| 225 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 226 | if( (mPipeBook[i].mDisplay == DPY_UNUSED || |
| 227 | mPipeBook[i].mDisplay == dpy) && |
| 228 | (mPipeBook[i].mMixer == MIXER_UNUSED || |
| 229 | mPipeBook[i].mMixer == mixer) && |
| 230 | PipeBook::isNotAllocated(i) && |
| 231 | !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE && |
| 232 | PipeBook::getPipeType((utils::eDest)i) == |
| 233 | utils::OV_MDP_PIPE_DMA)) { |
| 234 | avail++; |
Jeykumar Sankaran | ccb4460 | 2013-01-03 12:48:22 -0800 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | return avail; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 238 | } |
| 239 | |
Saurabh Shah | 082468e | 2013-09-12 10:05:32 -0700 | [diff] [blame] | 240 | inline int Overlay::availablePipes(int dpy) { |
| 241 | int avail = 0; |
| 242 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 243 | if( (mPipeBook[i].mDisplay == DPY_UNUSED || |
| 244 | mPipeBook[i].mDisplay == dpy) && |
| 245 | PipeBook::isNotAllocated(i) && |
| 246 | !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE && |
| 247 | PipeBook::getPipeType((utils::eDest)i) == |
| 248 | utils::OV_MDP_PIPE_DMA)) { |
| 249 | avail++; |
| 250 | } |
| 251 | } |
| 252 | return avail; |
| 253 | } |
| 254 | |
Saurabh Shah | 90b7b9b | 2013-09-12 16:36:08 -0700 | [diff] [blame] | 255 | inline int Overlay::availablePipes(int dpy, utils::eMdpPipeType type) { |
| 256 | int avail = 0; |
| 257 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 258 | if((mPipeBook[i].mDisplay == DPY_UNUSED || |
| 259 | mPipeBook[i].mDisplay == dpy) && |
| 260 | PipeBook::isNotAllocated(i) && |
| 261 | type == PipeBook::getPipeType((utils::eDest)i)) { |
| 262 | avail++; |
| 263 | } |
| 264 | } |
| 265 | return avail; |
| 266 | } |
| 267 | |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 268 | inline void Overlay::setDMAMode(const int& mode) { |
| 269 | if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE) |
| 270 | sDMAMode = mode; |
| 271 | } |
| 272 | |
| 273 | inline int Overlay::getDMAMode() { |
| 274 | return sDMAMode; |
| 275 | } |
| 276 | |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 277 | inline int Overlay::getFbForDpy(const int& dpy) { |
| 278 | OVASSERT(dpy >= 0 && dpy < DPY_MAX, "Invalid dpy %d", dpy); |
| 279 | return sDpyFbMap[dpy]; |
| 280 | } |
| 281 | |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame] | 282 | inline void Overlay::forceSet(const int& dpy) { |
| 283 | sForceSetBitmap |= (1 << dpy); |
| 284 | } |
| 285 | |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 286 | inline scale::Scale *Overlay::getScalar() { |
| 287 | return sScale; |
| 288 | } |
| 289 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 290 | inline bool Overlay::PipeBook::valid() { |
| 291 | return (mPipe != NULL); |
| 292 | } |
| 293 | |
| 294 | inline bool Overlay::PipeBook::pipeUsageUnchanged() { |
| 295 | return (sPipeUsageBitmap == sLastUsageBitmap); |
| 296 | } |
| 297 | |
| 298 | inline void Overlay::PipeBook::setUse(int index) { |
| 299 | sPipeUsageBitmap |= (1 << index); |
| 300 | } |
| 301 | |
| 302 | inline void Overlay::PipeBook::resetUse(int index) { |
| 303 | sPipeUsageBitmap &= ~(1 << index); |
| 304 | } |
| 305 | |
| 306 | inline bool Overlay::PipeBook::isUsed(int index) { |
| 307 | return sPipeUsageBitmap & (1 << index); |
| 308 | } |
| 309 | |
| 310 | inline bool Overlay::PipeBook::isNotUsed(int index) { |
| 311 | return !isUsed(index); |
| 312 | } |
| 313 | |
| 314 | inline void Overlay::PipeBook::save() { |
| 315 | sLastUsageBitmap = sPipeUsageBitmap; |
| 316 | } |
| 317 | |
| 318 | inline void Overlay::PipeBook::setAllocation(int index) { |
| 319 | sAllocatedBitmap |= (1 << index); |
| 320 | } |
| 321 | |
| 322 | inline void Overlay::PipeBook::resetAllocation(int index) { |
| 323 | sAllocatedBitmap &= ~(1 << index); |
| 324 | } |
| 325 | |
| 326 | inline bool Overlay::PipeBook::isAllocated(int index) { |
| 327 | return sAllocatedBitmap & (1 << index); |
| 328 | } |
| 329 | |
| 330 | inline bool Overlay::PipeBook::isNotAllocated(int index) { |
| 331 | return !isAllocated(index); |
| 332 | } |
| 333 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 334 | inline utils::eMdpPipeType Overlay::PipeBook::getPipeType(utils::eDest dest) { |
| 335 | return pipeTypeLUT[(int)dest]; |
| 336 | } |
| 337 | |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame^] | 338 | inline void Overlay::startSession(utils::eDest dest) { |
| 339 | mPipeBook[(int)dest].mSession = PipeBook::START; |
| 340 | } |
| 341 | |
| 342 | inline bool Overlay::sessionInProgress(utils::eDest dest) { |
| 343 | return (mPipeBook[(int)dest].mSession == PipeBook::START); |
| 344 | } |
| 345 | |
| 346 | inline bool Overlay::isSessionEnded(utils::eDest dest) { |
| 347 | return (mPipeBook[(int)dest].mSession == PipeBook::END); |
| 348 | } |
| 349 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 350 | inline const char* Overlay::PipeBook::getDestStr(utils::eDest dest) { |
| 351 | switch(getPipeType(dest)) { |
| 352 | case utils::OV_MDP_PIPE_RGB: return "RGB"; |
| 353 | case utils::OV_MDP_PIPE_VG: return "VG"; |
| 354 | case utils::OV_MDP_PIPE_DMA: return "DMA"; |
| 355 | default: return "Invalid"; |
| 356 | } |
| 357 | return "Invalid"; |
| 358 | } |
| 359 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 360 | }; // overlay |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 361 | |
| 362 | #endif // OVERLAY_H |