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