blob: affb4db753d74d1b7340f6c42888ad47829cbf24 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
Saurabh Shah5daeee52013-01-23 16:52:26 +08002* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Naseer Ahmed29a26812012-06-14 00:56:20 -07003*
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 Ahmed758bfc52012-11-28 17:02:08 -050013* * Neither the name of The Linux Foundation. nor the names of its
Naseer Ahmed29a26812012-06-14 00:56:20 -070014* 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 Kamala8c065f2013-10-22 14:52:45 +053034#include "mdp_version.h"
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080035#include "utils/threads.h"
Praveena Pachipulusu734118a2014-12-04 14:53:12 +053036#ifdef USES_POST_PROCESSING
37#include "lib-postproc.h"
38#endif
Naseer Ahmed29a26812012-06-14 00:56:20 -070039
Saurabh Shah5daeee52013-01-23 16:52:26 +080040struct MetaData_t;
41
Naseer Ahmed29a26812012-06-14 00:56:20 -070042namespace overlay {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050043class GenericPipe;
44
Naseer Ahmed29a26812012-06-14 00:56:20 -070045class Overlay : utils::NoCopy {
46public:
Saurabh Shah85234ec2013-04-12 17:09:00 -070047 enum { DMA_BLOCK_MODE, DMA_LINE_MODE };
Saurabh Shahc8118ac2013-06-27 10:03:19 -070048 //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 Shahaf5f5972013-07-30 13:56:35 -070053 enum { MIXER_LEFT, MIXER_RIGHT, MIXER_UNUSED };
54 enum { MIXER_DEFAULT = MIXER_LEFT, MIXER_MAX = MIXER_UNUSED };
Saurabh Shahc8118ac2013-06-27 10:03:19 -070055 enum { MAX_FB_DEVICES = DPY_MAX };
Baldev Sahu979e8f02014-11-12 15:35:13 +053056 enum { FORMAT_YUV, FORMAT_RGB , FORMAT_NONE };
Saurabh Shahc62f3982014-03-05 14:28:26 -080057
58 struct PipeSpecs {
59 PipeSpecs() : formatClass(FORMAT_RGB), needsScaling(false), fb(false),
Xu Yang1e686f62014-04-08 13:56:47 +080060 dpy(DPY_PRIMARY), mixer(MIXER_DEFAULT), numActiveDisplays(1) {}
Saurabh Shahc62f3982014-03-05 14:28:26 -080061 int formatClass;
62 bool needsScaling;
63 bool fb;
64 int dpy;
65 int mixer;
Xu Yang1e686f62014-04-08 13:56:47 +080066 int numActiveDisplays;
Saurabh Shahc62f3982014-03-05 14:28:26 -080067 };
Saurabh Shah85234ec2013-04-12 17:09:00 -070068
Naseer Ahmed29a26812012-06-14 00:56:20 -070069 /* dtor close */
70 ~Overlay();
71
Naseer Ahmed758bfc52012-11-28 17:02:08 -050072 /* 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 Ahmed29a26812012-06-14 00:56:20 -070076
Naseer Ahmed758bfc52012-11-28 17:02:08 -050077 /* 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 Ahmed29a26812012-06-14 00:56:20 -070083
Saurabh Shahc62f3982014-03-05 14:28:26 -080084 /* 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 Alam4b0a9242013-11-20 23:54:12 -050088 /* 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 Ahmedf48aef62012-07-20 09:05:53 -070097
Naseer Ahmed758bfc52012-11-28 17:02:08 -050098 void setSource(const utils::PipeArgs args, utils::eDest dest);
99 void setCrop(const utils::Dim& d, utils::eDest dest);
Sushil Chauhan897a9c32013-07-18 11:09:55 -0700100 void setColor(const uint32_t color, utils::eDest dest);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500101 void setTransform(const int orientation, utils::eDest dest);
102 void setPosition(const utils::Dim& dim, utils::eDest dest);
Saurabh Shah5daeee52013-01-23 16:52:26 +0800103 void setVisualParams(const MetaData_t& data, utils::eDest dest);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500104 bool commit(utils::eDest dest);
105 bool queueBuffer(int fd, uint32_t offset, utils::eDest dest);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700106
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500107 /* 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 Shahaf5f5972013-07-30 13:56:35 -0700115 /* Returns available ("unallocated") pipes for a display's mixer */
116 int availablePipes(int dpy, int mixer);
Saurabh Shah082468e2013-09-12 10:05:32 -0700117 /* Returns available ("unallocated") pipes for a display */
118 int availablePipes(int dpy);
Saurabh Shah90b7b9b2013-09-12 16:36:08 -0700119 /* Returns available ("unallocated") pipe of given type for a display */
120 int availablePipes(int dpy, utils::eMdpPipeType type);
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700121 /* Returns if any of the requested pipe type is attached to any of the
122 * displays
123 */
124 bool isPipeTypeAttached(utils::eMdpPipeType type);
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800125 /* Compare pipe priorities and return
Jeykumar Sankaran89e23ab2015-01-28 15:57:46 -0800126 * true - A swap is needed to fix the priority.
127 * false - Good, priority wise.
Saurabh Shahdd8237a2014-02-28 14:29:09 -0800128 */
Jeykumar Sankaran89e23ab2015-01-28 15:57:46 -0800129 bool needsPrioritySwap(utils::eDest pipe1Index, utils::eDest pipe2Index);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800130 /* Returns pipe dump. Expects a NULL terminated buffer of big enough size
131 * to populate.
132 */
Raj Kamal068f4572014-04-14 16:14:06 +0530133 /* Returns if DMA pipe multiplexing is supported by the mdss driver */
134 static bool isDMAMultiplexingSupported();
135 /* Returns if UI scaling on external is supported on the targets */
136 static bool isUIScalingOnExternalSupported();
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800137 void getDump(char *buf, size_t len);
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700138 /* Reset usage and allocation bits on all pipes for given display */
139 void clear(int dpy);
Saurabh Shaha36be922013-12-16 18:18:39 -0800140 /* Validate the set of pipes for a display and set them in driver */
141 bool validateAndSet(const int& dpy, const int& fbFd);
Saurabh Shah784e9852013-08-21 16:51:21 -0700142
143 /* Closes open pipes, called during startup */
144 static int initOverlay();
145 /* Returns the singleton instance of overlay */
146 static Overlay* getInstance();
Saurabh Shah85234ec2013-04-12 17:09:00 -0700147 static void setDMAMode(const int& mode);
148 static int getDMAMode();
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700149 /* Returns the framebuffer node backing up the display */
150 static int getFbForDpy(const int& dpy);
Jeykumar Sankaran6c7eeac2013-11-18 11:19:45 -0800151
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700152 static bool displayCommit(const int& fd);
Jeykumar Sankaran6c7eeac2013-11-18 11:19:45 -0800153 /* Overloads display commit with ROI's of each halves.
154 * Single interface panels will only update left ROI. */
155 static bool displayCommit(const int& fd, const utils::Dim& lRoi,
156 const utils::Dim& rRoi);
Saurabh Shah24eec8a2014-08-22 15:07:25 -0700157 /* Logs pipe lifecycle events like set, unset, commit when enabled */
158 static void debugPipeLifecycle(const bool& enable);
159 /* Returns true if pipe life cycle logging is enabled */
160 static bool isDebugPipeLifecycle();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700161
162private:
163 /* Ctor setup */
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500164 explicit Overlay();
165 /*Validate index range, abort if invalid */
166 void validate(int index);
Raj Kamala8c065f2013-10-22 14:52:45 +0530167 static void setDMAMultiplexingSupported();
Saurabh Shahc62f3982014-03-05 14:28:26 -0800168 /* Returns an available pipe based on the type of pipe requested. When ANY
169 * is requested, the first available VG or RGB is returned. If no pipe is
170 * available for the display "dpy" then INV is returned. Note: If a pipe is
171 * assigned to a certain display, then it cannot be assigned to another
172 * display without being garbage-collected once. To add if a pipe is
173 * asisgned to a mixer within a display it cannot be reused for another
174 * mixer without being UNSET once*/
Baldev Sahu979e8f02014-11-12 15:35:13 +0530175 utils::eDest nextPipe(utils::eMdpPipeType, const PipeSpecs& pipeSpecs);
Saurabh Shahc62f3982014-03-05 14:28:26 -0800176 /* Helpers that enfore target specific policies while returning pipes */
177 utils::eDest getPipe_8x26(const PipeSpecs& pipeSpecs);
178 utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs);
Prabhanjan Kandula958ffa92014-05-12 14:56:56 +0530179 utils::eDest getPipe_8x39(const PipeSpecs& pipeSpecs);
Prabhanjan Kandulafc541b32015-03-30 20:56:16 +0530180 utils::eDest getPipe_8x52(const PipeSpecs& pipeSpecs);
Saurabh Shah59788572014-07-29 10:07:57 -0700181 utils::eDest getPipe_8994(const PipeSpecs& pipeSpecs);
Saurabh Shahc62f3982014-03-05 14:28:26 -0800182
Saurabh Shaheac146b2014-05-13 11:36:20 -0700183 /* Returns the handle to libscale.so's programScale function */
184 static int (*getFnProgramScale())(struct mdp_overlay_list *);
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700185 /* Creates a scalar object using libscale.so */
186 static void initScalar();
187 /* Destroys the scalar object using libscale.so */
188 static void destroyScalar();
radhakrishna8ccb9082014-05-09 16:18:43 +0530189 /* Sets the pipe type RGB/VG/DMA*/
190 void setPipeType(utils::eDest pipeIndex, const utils::eMdpPipeType pType);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700191
Praveena Pachipulusu734118a2014-12-04 14:53:12 +0530192 /* Dynamically link ABL library */
193 static void initPostProc();
194 static void destroyPostProc();
195 static int (*getFnPpParams())(const struct compute_params *,
196 struct mdp_overlay_pp_params *);
197
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500198 /* Just like a Facebook for pipes, but much less profile info */
199 struct PipeBook {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500200 void init();
201 void destroy();
202 /* Check if pipe exists and return true, false otherwise */
203 bool valid();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700204
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500205 /* Hardware pipe wrapper */
206 GenericPipe *mPipe;
207 /* Display using this pipe. Refer to enums above */
208 int mDisplay;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700209 /* Mixer within a split display this pipe is attached to */
210 int mMixer;
Baldev Sahu979e8f02014-11-12 15:35:13 +0530211 /* Format for which this pipe is attached to the mixer*/
212 int mFormatType;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700213
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500214 /* operations on bitmap */
215 static bool pipeUsageUnchanged();
216 static void setUse(int index);
217 static void resetUse(int index);
218 static bool isUsed(int index);
219 static bool isNotUsed(int index);
220 static void save();
221
222 static void setAllocation(int index);
223 static void resetAllocation(int index);
224 static bool isAllocated(int index);
225 static bool isNotAllocated(int index);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500226
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800227 static utils::eMdpPipeType getPipeType(utils::eDest dest);
228 static const char* getDestStr(utils::eDest dest);
229
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500230 static int NUM_PIPES;
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800231 static utils::eMdpPipeType pipeTypeLUT[utils::OV_MAX];
Jeykumar Sankaran89e23ab2015-01-28 15:57:46 -0800232 static int pipeMinID[utils::OV_MDP_PIPE_ANY];
233 static int pipeMaxID[utils::OV_MDP_PIPE_ANY];
234
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500235 /* Session for reserved pipes */
236 enum Session {
237 NONE,
238 START,
239 END
240 };
241 Session mSession;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500242
243 private:
244 //usage tracks if a successful commit happened. So a pipe could be
245 //allocated to a display, but it may not end up using it for various
246 //reasons. If one display actually uses a pipe then it amy not be
247 //used by another display, without an UNSET in between.
248 static int sPipeUsageBitmap;
249 static int sLastUsageBitmap;
250 //Tracks which pipe objects are allocated. This does not imply that they
251 //will actually be used. For example, a display might choose to acquire
252 //3 pipe objects in one shot and proceed with config only if it gets all
253 //3. The bitmap helps allocate different pipe objects on each request.
254 static int sAllocatedBitmap;
255 };
256
257 PipeBook mPipeBook[utils::OV_INVALID]; //Used as max
258
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500259 /* Singleton Instance*/
260 static Overlay *sInstance;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700261 static int sDpyFbMap[DPY_MAX];
Saurabh Shah85234ec2013-04-12 17:09:00 -0700262 static int sDMAMode;
Raj Kamala8c065f2013-10-22 14:52:45 +0530263 static bool sDMAMultiplexingSupported;
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700264 static void *sLibScaleHandle;
Saurabh Shaheac146b2014-05-13 11:36:20 -0700265 static int (*sFnProgramScale)(struct mdp_overlay_list *);
Praveena Pachipulusu734118a2014-12-04 14:53:12 +0530266 /* Dynamically link ABL library */
267 static void *sLibAblHandle;
268 static int (*sFnppParams)(const struct compute_params *,
269 struct mdp_overlay_pp_params *);
Saurabh Shah24eec8a2014-08-22 15:07:25 -0700270 static bool sDebugPipeLifecycle;
Saurabh Shaha36be922013-12-16 18:18:39 -0800271
272 friend class MdpCtrl;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700273};
274
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500275inline void Overlay::validate(int index) {
276 OVASSERT(index >=0 && index < PipeBook::NUM_PIPES, \
277 "%s, Index out of bounds: %d", __FUNCTION__, index);
278 OVASSERT(mPipeBook[index].valid(), "Pipe does not exist %s",
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800279 PipeBook::getDestStr((utils::eDest)index));
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500280}
281
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700282inline int Overlay::availablePipes(int dpy, int mixer) {
283 int avail = 0;
284 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
285 if( (mPipeBook[i].mDisplay == DPY_UNUSED ||
286 mPipeBook[i].mDisplay == dpy) &&
287 (mPipeBook[i].mMixer == MIXER_UNUSED ||
288 mPipeBook[i].mMixer == mixer) &&
289 PipeBook::isNotAllocated(i) &&
290 !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE &&
291 PipeBook::getPipeType((utils::eDest)i) ==
292 utils::OV_MDP_PIPE_DMA)) {
293 avail++;
Jeykumar Sankaranccb44602013-01-03 12:48:22 -0800294 }
295 }
296 return avail;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500297}
298
Saurabh Shah082468e2013-09-12 10:05:32 -0700299inline int Overlay::availablePipes(int dpy) {
300 int avail = 0;
301 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
302 if( (mPipeBook[i].mDisplay == DPY_UNUSED ||
303 mPipeBook[i].mDisplay == dpy) &&
304 PipeBook::isNotAllocated(i) &&
305 !(Overlay::getDMAMode() == Overlay::DMA_BLOCK_MODE &&
306 PipeBook::getPipeType((utils::eDest)i) ==
307 utils::OV_MDP_PIPE_DMA)) {
308 avail++;
309 }
310 }
311 return avail;
312}
313
Saurabh Shah90b7b9b2013-09-12 16:36:08 -0700314inline int Overlay::availablePipes(int dpy, utils::eMdpPipeType type) {
315 int avail = 0;
316 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
317 if((mPipeBook[i].mDisplay == DPY_UNUSED ||
318 mPipeBook[i].mDisplay == dpy) &&
319 PipeBook::isNotAllocated(i) &&
320 type == PipeBook::getPipeType((utils::eDest)i)) {
321 avail++;
322 }
323 }
324 return avail;
325}
326
Saurabh Shah85234ec2013-04-12 17:09:00 -0700327inline void Overlay::setDMAMode(const int& mode) {
328 if(mode == DMA_LINE_MODE || mode == DMA_BLOCK_MODE)
329 sDMAMode = mode;
330}
331
Raj Kamala8c065f2013-10-22 14:52:45 +0530332inline void Overlay::setDMAMultiplexingSupported() {
333 sDMAMultiplexingSupported = false;
334 if(qdutils::MDPVersion::getInstance().is8x26())
335 sDMAMultiplexingSupported = true;
336}
337
Raj Kamal068f4572014-04-14 16:14:06 +0530338inline bool Overlay::isDMAMultiplexingSupported() {
339 return sDMAMultiplexingSupported;
340}
341
342inline bool Overlay::isUIScalingOnExternalSupported() {
343 if(qdutils::MDPVersion::getInstance().is8x26() or
Prabhanjan Kandula958ffa92014-05-12 14:56:56 +0530344 qdutils::MDPVersion::getInstance().is8x16() or
Prabhanjan Kandulafc541b32015-03-30 20:56:16 +0530345 qdutils::MDPVersion::getInstance().is8x39() or
346 qdutils::MDPVersion::getInstance().is8x52()) {
Raj Kamal068f4572014-04-14 16:14:06 +0530347 return false;
348 }
349 return true;
350}
351
Saurabh Shah85234ec2013-04-12 17:09:00 -0700352inline int Overlay::getDMAMode() {
353 return sDMAMode;
354}
355
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700356inline int Overlay::getFbForDpy(const int& dpy) {
357 OVASSERT(dpy >= 0 && dpy < DPY_MAX, "Invalid dpy %d", dpy);
358 return sDpyFbMap[dpy];
359}
360
Saurabh Shaheac146b2014-05-13 11:36:20 -0700361inline int (*Overlay::getFnProgramScale())(struct mdp_overlay_list *) {
362 return sFnProgramScale;
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700363}
364
Praveena Pachipulusu734118a2014-12-04 14:53:12 +0530365inline int (*Overlay::getFnPpParams())(const struct compute_params *,
366 struct mdp_overlay_pp_params *) {
367 return sFnppParams;
368}
369
Saurabh Shah24eec8a2014-08-22 15:07:25 -0700370inline void Overlay::debugPipeLifecycle(const bool& enable) {
371 sDebugPipeLifecycle = enable;
372}
373
374inline bool Overlay::isDebugPipeLifecycle() {
375 return sDebugPipeLifecycle;
376}
377
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500378inline bool Overlay::PipeBook::valid() {
379 return (mPipe != NULL);
380}
381
382inline bool Overlay::PipeBook::pipeUsageUnchanged() {
383 return (sPipeUsageBitmap == sLastUsageBitmap);
384}
385
386inline void Overlay::PipeBook::setUse(int index) {
387 sPipeUsageBitmap |= (1 << index);
388}
389
390inline void Overlay::PipeBook::resetUse(int index) {
391 sPipeUsageBitmap &= ~(1 << index);
392}
393
394inline bool Overlay::PipeBook::isUsed(int index) {
395 return sPipeUsageBitmap & (1 << index);
396}
397
398inline bool Overlay::PipeBook::isNotUsed(int index) {
399 return !isUsed(index);
400}
401
402inline void Overlay::PipeBook::save() {
403 sLastUsageBitmap = sPipeUsageBitmap;
404}
405
406inline void Overlay::PipeBook::setAllocation(int index) {
407 sAllocatedBitmap |= (1 << index);
408}
409
410inline void Overlay::PipeBook::resetAllocation(int index) {
411 sAllocatedBitmap &= ~(1 << index);
412}
413
414inline bool Overlay::PipeBook::isAllocated(int index) {
415 return sAllocatedBitmap & (1 << index);
416}
417
418inline bool Overlay::PipeBook::isNotAllocated(int index) {
419 return !isAllocated(index);
420}
421
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800422inline utils::eMdpPipeType Overlay::PipeBook::getPipeType(utils::eDest dest) {
423 return pipeTypeLUT[(int)dest];
424}
425
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500426inline void Overlay::startSession(utils::eDest dest) {
427 mPipeBook[(int)dest].mSession = PipeBook::START;
428}
429
430inline bool Overlay::sessionInProgress(utils::eDest dest) {
431 return (mPipeBook[(int)dest].mSession == PipeBook::START);
432}
433
434inline bool Overlay::isSessionEnded(utils::eDest dest) {
435 return (mPipeBook[(int)dest].mSession == PipeBook::END);
436}
437
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800438inline const char* Overlay::PipeBook::getDestStr(utils::eDest dest) {
439 switch(getPipeType(dest)) {
440 case utils::OV_MDP_PIPE_RGB: return "RGB";
441 case utils::OV_MDP_PIPE_VG: return "VG";
442 case utils::OV_MDP_PIPE_DMA: return "DMA";
443 default: return "Invalid";
444 }
445 return "Invalid";
446}
447
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500448}; // overlay
Naseer Ahmed29a26812012-06-14 00:56:20 -0700449
450#endif // OVERLAY_H