Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
Ramakant Singh | b4106a1 | 2014-10-07 18:06:56 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2014, 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 | |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 30 | #include <dlfcn.h> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 31 | #include "overlay.h" |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 32 | #include "pipes/overlayGenPipe.h" |
| 33 | #include "mdp_version.h" |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 34 | #include "qdMetaData.h" |
Tatenda Chipeperekwa | ce8d5c4 | 2014-08-13 10:53:49 -0700 | [diff] [blame] | 35 | #include "qd_utils.h" |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 36 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 37 | namespace overlay { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 38 | using namespace utils; |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 39 | using namespace qdutils; |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 40 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 41 | Overlay::Overlay() { |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame] | 42 | int numPipes = qdutils::MDPVersion::getInstance().getTotalPipes(); |
| 43 | PipeBook::NUM_PIPES = (numPipes <= utils::OV_MAX)? numPipes : utils::OV_MAX; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 44 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 45 | mPipeBook[i].init(); |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 46 | } |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 47 | |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 48 | initScalar(); |
Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 49 | setDMAMultiplexingSupported(); |
Praveena Pachipulusu | 734118a | 2014-12-04 14:53:12 +0530 | [diff] [blame] | 50 | #ifdef USES_POST_PROCESSING |
| 51 | initPostProc(); |
| 52 | #endif |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | Overlay::~Overlay() { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 56 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 57 | mPipeBook[i].destroy(); |
| 58 | } |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 59 | destroyScalar(); |
Praveena Pachipulusu | 734118a | 2014-12-04 14:53:12 +0530 | [diff] [blame] | 60 | #ifdef USES_POST_PROCESSING |
| 61 | destroyPostProc(); |
| 62 | #endif |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 65 | void Overlay::configBegin() { |
| 66 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 67 | //Mark as available for this round. |
| 68 | PipeBook::resetUse(i); |
| 69 | PipeBook::resetAllocation(i); |
| 70 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void Overlay::configDone() { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 74 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 75 | if((PipeBook::isNotUsed(i) && !sessionInProgress((eDest)i)) || |
| 76 | isSessionEnded((eDest)i)) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 77 | //Forces UNSET on pipes, flushes rotator memory and session, closes |
| 78 | //fds |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 79 | mPipeBook[i].destroy(); |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 80 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 81 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 82 | PipeBook::save(); |
| 83 | } |
| 84 | |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 85 | int Overlay::getPipeId(utils::eDest dest) { |
| 86 | return mPipeBook[(int)dest].mPipe->getPipeId(); |
| 87 | } |
| 88 | |
| 89 | eDest Overlay::getDest(int pipeid) { |
| 90 | eDest dest = OV_INVALID; |
| 91 | // finding the dest corresponding to the given pipe |
| 92 | for(int i=0; i < PipeBook::NUM_PIPES; ++i) { |
| 93 | if(mPipeBook[i].valid() && mPipeBook[i].mPipe->getPipeId() == pipeid) { |
| 94 | return (eDest)i; |
| 95 | } |
| 96 | } |
| 97 | return dest; |
| 98 | } |
| 99 | |
| 100 | eDest Overlay::reservePipe(int pipeid) { |
| 101 | eDest dest = getDest(pipeid); |
| 102 | PipeBook::setAllocation((int)dest); |
| 103 | return dest; |
| 104 | } |
| 105 | |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 106 | eDest Overlay::nextPipe(eMdpPipeType type, const PipeSpecs& pipeSpecs) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 107 | eDest dest = OV_INVALID; |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 108 | int dpy = pipeSpecs.dpy; |
| 109 | int mixer = pipeSpecs.mixer; |
| 110 | int formatType = pipeSpecs.formatClass; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 111 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 112 | if( (type == OV_MDP_PIPE_ANY || //Pipe type match |
| 113 | type == PipeBook::getPipeType((eDest)i)) && |
| 114 | (mPipeBook[i].mDisplay == DPY_UNUSED || //Free or same display |
| 115 | mPipeBook[i].mDisplay == dpy) && |
| 116 | (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer |
| 117 | mPipeBook[i].mMixer == mixer) && |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 118 | (mPipeBook[i].mFormatType == FORMAT_NONE || //Free or same format |
| 119 | mPipeBook[i].mFormatType == formatType) && |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 120 | PipeBook::isNotAllocated(i) && //Free pipe |
Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 121 | ( (sDMAMultiplexingSupported && dpy) || |
| 122 | !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode |
| 123 | PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) ){ |
| 124 | //DMA-Multiplexing is only supported for WB on 8x26 |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 125 | dest = (eDest)i; |
| 126 | PipeBook::setAllocation(i); |
| 127 | break; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | if(dest != OV_INVALID) { |
| 132 | int index = (int)dest; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 133 | mPipeBook[index].mDisplay = dpy; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 134 | mPipeBook[index].mMixer = mixer; |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 135 | mPipeBook[index].mFormatType = formatType; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 136 | if(not mPipeBook[index].valid()) { |
| 137 | mPipeBook[index].mPipe = new GenericPipe(dpy); |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 138 | mPipeBook[index].mSession = PipeBook::NONE; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 139 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | return dest; |
| 143 | } |
| 144 | |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 145 | utils::eDest Overlay::getPipe(const PipeSpecs& pipeSpecs) { |
| 146 | if(MDPVersion::getInstance().is8x26()) { |
| 147 | return getPipe_8x26(pipeSpecs); |
| 148 | } else if(MDPVersion::getInstance().is8x16()) { |
| 149 | return getPipe_8x16(pipeSpecs); |
Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 150 | } else if(MDPVersion::getInstance().is8x39()) { |
| 151 | return getPipe_8x39(pipeSpecs); |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 152 | } else if(MDPVersion::getInstance().is8994()) { |
| 153 | return getPipe_8994(pipeSpecs); |
Ramkumar Radhakrishnan | 87a1cd1 | 2015-02-25 17:47:29 -0800 | [diff] [blame^] | 154 | } else if(MDPVersion::getInstance().is8992()) { |
| 155 | return getPipe_8992(pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | eDest dest = OV_INVALID; |
| 159 | |
| 160 | //The default behavior is to assume RGB and VG pipes have scalars |
| 161 | if(pipeSpecs.formatClass == FORMAT_YUV) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 162 | return nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 163 | } else if(pipeSpecs.fb == false) { //RGB App layers |
| 164 | if(not pipeSpecs.needsScaling) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 165 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 166 | } |
| 167 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 168 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 169 | } |
| 170 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 171 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 172 | } |
| 173 | } else { //FB layer |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 174 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 175 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 176 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 177 | } |
| 178 | //Some features can cause FB to have scaling as well. |
| 179 | //If we ever come to this block with FB needing scaling, |
| 180 | //the screen will be black for a frame, since the FB won't get a pipe |
| 181 | //but atleast this will prevent a hang |
| 182 | if(dest == OV_INVALID and (not pipeSpecs.needsScaling)) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 183 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | return dest; |
| 187 | } |
| 188 | |
| 189 | utils::eDest Overlay::getPipe_8x26(const PipeSpecs& pipeSpecs) { |
| 190 | //Use this to hide all the 8x26 requirements that cannot be humanly |
| 191 | //described in a generic way |
| 192 | eDest dest = OV_INVALID; |
| 193 | if(pipeSpecs.formatClass == FORMAT_YUV) { //video |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 194 | return nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 195 | } else if(pipeSpecs.fb == false) { //RGB app layers |
Xu Yang | 1e686f6 | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 196 | if((not pipeSpecs.needsScaling) and |
| 197 | (not (pipeSpecs.numActiveDisplays > 1 && |
| 198 | pipeSpecs.dpy == DPY_PRIMARY))) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 199 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 200 | } |
| 201 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 202 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 203 | } |
| 204 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 205 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 206 | } |
| 207 | } else { //FB layer |
| 208 | //For 8x26 Secondary we use DMA always for FB for inline rotation |
| 209 | if(pipeSpecs.dpy == DPY_PRIMARY) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 210 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 211 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 212 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 213 | } |
| 214 | } |
Xu Yang | 1e686f6 | 2014-04-08 13:56:47 +0800 | [diff] [blame] | 215 | if(dest == OV_INVALID and (not pipeSpecs.needsScaling) and |
| 216 | (not (pipeSpecs.numActiveDisplays > 1 && |
| 217 | pipeSpecs.dpy == DPY_PRIMARY))) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 218 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | return dest; |
| 222 | } |
| 223 | |
| 224 | utils::eDest Overlay::getPipe_8x16(const PipeSpecs& pipeSpecs) { |
| 225 | //Having such functions help keeping the interface generic but code specific |
| 226 | //and rife with assumptions |
| 227 | eDest dest = OV_INVALID; |
| 228 | if(pipeSpecs.formatClass == FORMAT_YUV or pipeSpecs.needsScaling) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 229 | return nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
radhakrishna | 8929846 | 2014-04-22 19:10:36 +0530 | [diff] [blame] | 230 | } else { |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 231 | //Since this is a specific func, we can assume stuff like RGB pipe not |
| 232 | //having scalar blocks |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 233 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 234 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 235 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 236 | } |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 237 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 238 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | c62f398 | 2014-03-05 14:28:26 -0800 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | return dest; |
| 242 | } |
| 243 | |
Prabhanjan Kandula | 958ffa9 | 2014-05-12 14:56:56 +0530 | [diff] [blame] | 244 | utils::eDest Overlay::getPipe_8x39(const PipeSpecs& pipeSpecs) { |
| 245 | //8x16 & 8x36 has same number of pipes, pipe-types & scaling capabilities. |
| 246 | //Rely on 8x16 until we see a need to change. |
| 247 | return getPipe_8x16(pipeSpecs); |
| 248 | } |
| 249 | |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 250 | utils::eDest Overlay::getPipe_8994(const PipeSpecs& pipeSpecs) { |
| 251 | //If DMA pipes need to be used in block mode for downscale, there could be |
| 252 | //cases where consecutive rounds need separate modes, which cannot be |
| 253 | //supported since we at least need 1 round in between where the DMA is |
| 254 | //unused |
| 255 | eDest dest = OV_INVALID; |
Ramkumar Radhakrishnan | 87a1cd1 | 2015-02-25 17:47:29 -0800 | [diff] [blame^] | 256 | |
| 257 | // Reset format type to FORMAT_NONE to select the pipe irrespective of the |
| 258 | // format specifed by the client. This is required for the device where |
| 259 | // SMP starvation is unlikely, we need not keep track of formats |
| 260 | // programmed in the pipes to avoid potential pipe crunching. |
| 261 | resetPipeBookFormat(pipeSpecs.dpy); |
| 262 | |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 263 | if(pipeSpecs.formatClass == FORMAT_YUV) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 264 | return nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 265 | } else { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 266 | dest = nextPipe(OV_MDP_PIPE_RGB, pipeSpecs); |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 267 | if(dest == OV_INVALID) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 268 | dest = nextPipe(OV_MDP_PIPE_VG, pipeSpecs); |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 269 | } |
| 270 | if(dest == OV_INVALID and not pipeSpecs.needsScaling) { |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 271 | dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs); |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 272 | } |
| 273 | } |
Ramkumar Radhakrishnan | 87a1cd1 | 2015-02-25 17:47:29 -0800 | [diff] [blame^] | 274 | |
Saurabh Shah | 5978857 | 2014-07-29 10:07:57 -0700 | [diff] [blame] | 275 | return dest; |
| 276 | } |
| 277 | |
Ramkumar Radhakrishnan | 87a1cd1 | 2015-02-25 17:47:29 -0800 | [diff] [blame^] | 278 | utils::eDest Overlay::getPipe_8992(const PipeSpecs& pipeSpecs) { |
| 279 | return getPipe_8994(pipeSpecs); |
| 280 | } |
| 281 | |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 282 | void Overlay::endAllSessions() { |
| 283 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 284 | if(mPipeBook[i].valid() && mPipeBook[i].mSession==PipeBook::START) |
| 285 | mPipeBook[i].mSession = PipeBook::END; |
| 286 | } |
| 287 | } |
| 288 | |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 289 | bool Overlay::isPipeTypeAttached(eMdpPipeType type) { |
| 290 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 291 | if(type == PipeBook::getPipeType((eDest)i) && |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 292 | mPipeBook[i].mDisplay != DPY_UNUSED) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 293 | return true; |
| 294 | } |
| 295 | } |
| 296 | return false; |
| 297 | } |
| 298 | |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 299 | bool Overlay::needsPrioritySwap(utils::eDest pipe1Index, |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 300 | utils::eDest pipe2Index) { |
| 301 | validate((int)pipe1Index); |
| 302 | validate((int)pipe2Index); |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 303 | |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 304 | uint8_t pipe1Prio = mPipeBook[(int)pipe1Index].mPipe->getPriority(); |
| 305 | uint8_t pipe2Prio = mPipeBook[(int)pipe2Index].mPipe->getPriority(); |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 306 | |
| 307 | int pipe1Id = mPipeBook[(int)pipe1Index].mPipe->getPipeId(); |
| 308 | int pipe2Id = mPipeBook[(int)pipe2Index].mPipe->getPipeId(); |
| 309 | |
| 310 | utils::eMdpPipeType leftType = PipeBook::getPipeType(pipe1Index); |
| 311 | utils::eMdpPipeType rightType = PipeBook::getPipeType(pipe2Index); |
| 312 | |
| 313 | if(pipe1Id >=0 && pipe2Id >=0) { |
| 314 | // LEFT priority should be higher then RIGHT |
| 315 | return (pipe1Prio > pipe2Prio); |
| 316 | } else if(pipe1Id < 0 && pipe2Id < 0) { |
Saurabh Shah | ea3cf30 | 2014-11-07 12:10:46 -0800 | [diff] [blame] | 317 | // If we are here, Source Split is enabled and both pipes are |
| 318 | // new requests. In this case left type should be of higher prio |
| 319 | // than right type |
Saurabh Shah | ea3cf30 | 2014-11-07 12:10:46 -0800 | [diff] [blame] | 320 | if(leftType == rightType) { |
| 321 | //Safe. Onus on driver to assign correct pipes within same type |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 322 | return false; |
Saurabh Shah | 218a61a | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 323 | } else { |
Saurabh Shah | ea3cf30 | 2014-11-07 12:10:46 -0800 | [diff] [blame] | 324 | //This check takes advantage of having only 3 types and avoids 3 |
| 325 | //different failure combination checks. |
Saurabh Shah | 218a61a | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 326 | // Swap IF: |
| 327 | // ---------------- |
| 328 | // | Left | Right | |
| 329 | // ================ |
| 330 | // | DMA | ViG | |
| 331 | // ---------------- |
| 332 | // | DMA | RGB | |
| 333 | // ---------------- |
| 334 | // | RGB | ViG | |
| 335 | // ---------------- |
| 336 | return (leftType == OV_MDP_PIPE_DMA or rightType == OV_MDP_PIPE_VG); |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 337 | } |
| 338 | } else if(pipe1Id < 0) { |
| 339 | //LEFT needs new allocation. |
| 340 | if(leftType == rightType) { |
| 341 | // If RIGHT has highest priority(lowest id), swap it. |
| 342 | return (pipe2Id == PipeBook::pipeMinID[leftType]); |
| 343 | } else { |
Saurabh Shah | 218a61a | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 344 | return (leftType == OV_MDP_PIPE_DMA or rightType == OV_MDP_PIPE_VG); |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 345 | } |
| 346 | } else { /* if (pipe2Id < 0) */ |
| 347 | // RIGHT needs new allocation. |
| 348 | if(leftType == rightType) { |
| 349 | // If LEFT has lowest priority(highest id), swap it. |
| 350 | return (pipe1Id == PipeBook::pipeMaxID[leftType]); |
| 351 | } else { |
Saurabh Shah | 218a61a | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 352 | return (leftType == OV_MDP_PIPE_DMA or rightType == OV_MDP_PIPE_VG); |
Saurabh Shah | ea3cf30 | 2014-11-07 12:10:46 -0800 | [diff] [blame] | 353 | } |
| 354 | } |
Saurabh Shah | dd8237a | 2014-02-28 14:29:09 -0800 | [diff] [blame] | 355 | } |
| 356 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 357 | bool Overlay::commit(utils::eDest dest) { |
| 358 | bool ret = false; |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 359 | validate((int)dest); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 360 | |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 361 | if(mPipeBook[dest].mPipe->commit()) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 362 | ret = true; |
| 363 | PipeBook::setUse((int)dest); |
| 364 | } else { |
Saurabh Shah | 7cd6778 | 2014-11-12 10:33:19 -0800 | [diff] [blame] | 365 | clear(mPipeBook[dest].mDisplay); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 366 | } |
| 367 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 370 | bool Overlay::queueBuffer(int fd, uint32_t offset, |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 371 | utils::eDest dest) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 372 | bool ret = false; |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 373 | validate((int)dest); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 374 | //Queue only if commit() has succeeded (and the bit set) |
| 375 | if(PipeBook::isUsed((int)dest)) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 376 | ret = mPipeBook[dest].mPipe->queueBuffer(fd, offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 377 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 378 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 379 | } |
| 380 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 381 | void Overlay::setCrop(const utils::Dim& d, |
| 382 | utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 383 | validate((int)dest); |
| 384 | mPipeBook[dest].mPipe->setCrop(d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 385 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 386 | |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 387 | void Overlay::setColor(const uint32_t color, |
| 388 | utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 389 | validate((int)dest); |
| 390 | mPipeBook[dest].mPipe->setColor(color); |
Sushil Chauhan | 897a9c3 | 2013-07-18 11:09:55 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 393 | void Overlay::setPosition(const utils::Dim& d, |
| 394 | utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 395 | validate((int)dest); |
| 396 | mPipeBook[dest].mPipe->setPosition(d); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | void Overlay::setTransform(const int orient, |
| 400 | utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 401 | validate((int)dest); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 402 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 403 | utils::eTransform transform = |
| 404 | static_cast<utils::eTransform>(orient); |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 405 | mPipeBook[dest].mPipe->setTransform(transform); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 406 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | void Overlay::setSource(const utils::PipeArgs args, |
| 410 | utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 411 | validate((int)dest); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 412 | |
radhakrishna | 8ccb908 | 2014-05-09 16:18:43 +0530 | [diff] [blame] | 413 | setPipeType(dest, PipeBook::getPipeType(dest)); |
| 414 | mPipeBook[dest].mPipe->setSource(args); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 415 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 416 | |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 417 | void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) { |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 418 | validate((int)dest); |
| 419 | mPipeBook[dest].mPipe->setVisualParams(metadata); |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 420 | } |
| 421 | |
radhakrishna | 8ccb908 | 2014-05-09 16:18:43 +0530 | [diff] [blame] | 422 | void Overlay::setPipeType(utils::eDest pipeIndex, |
| 423 | const utils::eMdpPipeType pType) { |
| 424 | mPipeBook[pipeIndex].mPipe->setPipeType(pType); |
| 425 | } |
| 426 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 427 | Overlay* Overlay::getInstance() { |
| 428 | if(sInstance == NULL) { |
| 429 | sInstance = new Overlay(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 430 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 431 | return sInstance; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 432 | } |
| 433 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 434 | // Clears any VG pipes allocated to the fb devices |
| 435 | // Generates a LUT for pipe types. |
| 436 | int Overlay::initOverlay() { |
| 437 | int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion(); |
| 438 | int numPipesXType[OV_MDP_PIPE_ANY] = {0}; |
| 439 | numPipesXType[OV_MDP_PIPE_RGB] = |
| 440 | qdutils::MDPVersion::getInstance().getRGBPipes(); |
| 441 | numPipesXType[OV_MDP_PIPE_VG] = |
| 442 | qdutils::MDPVersion::getInstance().getVGPipes(); |
| 443 | numPipesXType[OV_MDP_PIPE_DMA] = |
| 444 | qdutils::MDPVersion::getInstance().getDMAPipes(); |
| 445 | |
| 446 | int index = 0; |
| 447 | for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types |
| 448 | for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num |
| 449 | PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X; |
| 450 | index++; |
| 451 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 452 | } |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 453 | |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 454 | PipeBook::pipeMinID[OV_MDP_PIPE_RGB] = 8; |
| 455 | PipeBook::pipeMaxID[OV_MDP_PIPE_RGB] = (numPipesXType[OV_MDP_PIPE_RGB] == 3)? 32 : 512; |
| 456 | PipeBook::pipeMinID[OV_MDP_PIPE_VG] = 1; |
| 457 | PipeBook::pipeMaxID[OV_MDP_PIPE_VG] = (numPipesXType[OV_MDP_PIPE_VG] == 3)? 4 : 256; |
| 458 | PipeBook::pipeMinID[OV_MDP_PIPE_DMA] = 64; |
| 459 | PipeBook::pipeMaxID[OV_MDP_PIPE_DMA] = 128; |
| 460 | |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 461 | FILE *displayDeviceFP = NULL; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 462 | char fbType[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 463 | char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 464 | const char *strDtvPanel = "dtv panel"; |
| 465 | const char *strWbPanel = "writeback panel"; |
| 466 | |
| 467 | for(int num = 1; num < MAX_FB_DEVICES; num++) { |
| 468 | snprintf (msmFbTypePath, sizeof(msmFbTypePath), |
| 469 | "/sys/class/graphics/fb%d/msm_fb_type", num); |
| 470 | displayDeviceFP = fopen(msmFbTypePath, "r"); |
| 471 | |
| 472 | if(displayDeviceFP){ |
| 473 | fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE, |
| 474 | displayDeviceFP); |
| 475 | |
| 476 | if(strncmp(fbType, strDtvPanel, strlen(strDtvPanel)) == 0) { |
| 477 | sDpyFbMap[DPY_EXTERNAL] = num; |
| 478 | } else if(strncmp(fbType, strWbPanel, strlen(strWbPanel)) == 0) { |
| 479 | sDpyFbMap[DPY_WRITEBACK] = num; |
| 480 | } |
| 481 | |
| 482 | fclose(displayDeviceFP); |
| 483 | } |
| 484 | } |
| 485 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 486 | return 0; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 487 | } |
| 488 | |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 489 | bool Overlay::displayCommit(const int& fd) { |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 490 | utils::Dim lRoi, rRoi; |
| 491 | return displayCommit(fd, lRoi, rRoi); |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 492 | } |
| 493 | |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 494 | bool Overlay::displayCommit(const int& fd, const utils::Dim& lRoi, |
| 495 | const utils::Dim& rRoi) { |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 496 | //Commit |
| 497 | struct mdp_display_commit info; |
| 498 | memset(&info, 0, sizeof(struct mdp_display_commit)); |
| 499 | info.flags = MDP_DISPLAY_COMMIT_OVERLAY; |
Jeykumar Sankaran | 6c7eeac | 2013-11-18 11:19:45 -0800 | [diff] [blame] | 500 | info.l_roi.x = lRoi.x; |
| 501 | info.l_roi.y = lRoi.y; |
| 502 | info.l_roi.w = lRoi.w; |
| 503 | info.l_roi.h = lRoi.h; |
| 504 | info.r_roi.x = rRoi.x; |
| 505 | info.r_roi.y = rRoi.y; |
| 506 | info.r_roi.w = rRoi.w; |
| 507 | info.r_roi.h = rRoi.h; |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 508 | |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 509 | if(!mdp_wrapper::displayCommit(fd, info)) { |
Jeykumar Sankaran | 6a9bb9e | 2013-08-01 14:19:26 -0700 | [diff] [blame] | 510 | ALOGE("%s: commit failed", __func__); |
| 511 | return false; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 512 | } |
| 513 | return true; |
| 514 | } |
| 515 | |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 516 | void Overlay::getDump(char *buf, size_t len) { |
| 517 | int totalPipes = 0; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 518 | const char *str = "\nOverlay State\n\n"; |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame] | 519 | strlcat(buf, str, len); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 520 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 521 | if(mPipeBook[i].valid()) { |
| 522 | mPipeBook[i].mPipe->getDump(buf, len); |
| 523 | char str[64] = {'\0'}; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 524 | snprintf(str, 64, "Display=%d\n\n", mPipeBook[i].mDisplay); |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame] | 525 | strlcat(buf, str, len); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 526 | totalPipes++; |
| 527 | } |
| 528 | } |
| 529 | char str_pipes[64] = {'\0'}; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 530 | snprintf(str_pipes, 64, "Pipes=%d\n\n", totalPipes); |
Ramkumar Radhakrishnan | 36bd527 | 2014-01-31 20:03:01 -0800 | [diff] [blame] | 531 | strlcat(buf, str_pipes, len); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 532 | } |
| 533 | |
Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 534 | void Overlay::clear(int dpy) { |
| 535 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 536 | if (mPipeBook[i].mDisplay == dpy) { |
| 537 | // Mark as available for this round |
| 538 | PipeBook::resetUse(i); |
| 539 | PipeBook::resetAllocation(i); |
Saurabh Shah | 7cd6778 | 2014-11-12 10:33:19 -0800 | [diff] [blame] | 540 | if(getPipeId((utils::eDest)i) == -1) { |
| 541 | mPipeBook[i].destroy(); |
| 542 | } |
Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | } |
| 546 | |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 547 | bool Overlay::validateAndSet(const int& dpy, const int& fbFd) { |
| 548 | GenericPipe* pipeArray[PipeBook::NUM_PIPES]; |
Praveena Pachipulusu | 2005e8f | 2014-05-07 20:01:54 +0530 | [diff] [blame] | 549 | memset(pipeArray, 0, sizeof(GenericPipe*)*(PipeBook::NUM_PIPES)); |
Saurabh Shah | a36be92 | 2013-12-16 18:18:39 -0800 | [diff] [blame] | 550 | |
| 551 | int num = 0; |
| 552 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 553 | if(PipeBook::isUsed(i) && mPipeBook[i].valid() && |
| 554 | mPipeBook[i].mDisplay == dpy) { |
| 555 | pipeArray[num++] = mPipeBook[i].mPipe; |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | //Protect against misbehaving clients |
| 560 | return num ? GenericPipe::validateAndSet(pipeArray, num, fbFd) : true; |
| 561 | } |
| 562 | |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 563 | void Overlay::initScalar() { |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 564 | if(sLibScaleHandle == NULL) { |
| 565 | sLibScaleHandle = dlopen("libscale.so", RTLD_NOW); |
Saurabh Shah | eac146b | 2014-05-13 11:36:20 -0700 | [diff] [blame] | 566 | if(sLibScaleHandle) { |
| 567 | *(void **) &sFnProgramScale = |
| 568 | dlsym(sLibScaleHandle, "programScale"); |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | void Overlay::destroyScalar() { |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 574 | if(sLibScaleHandle) { |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 575 | dlclose(sLibScaleHandle); |
| 576 | sLibScaleHandle = NULL; |
| 577 | } |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Praveena Pachipulusu | 734118a | 2014-12-04 14:53:12 +0530 | [diff] [blame] | 580 | void Overlay::initPostProc() { |
| 581 | sLibAblHandle = dlopen("libmm-abl.so", RTLD_NOW); |
| 582 | if (sLibAblHandle) { |
| 583 | *(void **)&sFnppParams = dlsym(sLibAblHandle, |
| 584 | "display_pp_compute_params"); |
| 585 | } else { |
| 586 | ALOGE("%s: Not able to load libmm-abl.so", __FUNCTION__); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | void Overlay::destroyPostProc() { |
| 591 | if (sLibAblHandle) { |
| 592 | dlclose(sLibAblHandle); |
| 593 | sLibAblHandle = NULL; |
| 594 | } |
| 595 | } |
| 596 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 597 | void Overlay::PipeBook::init() { |
| 598 | mPipe = NULL; |
| 599 | mDisplay = DPY_UNUSED; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 600 | mMixer = MIXER_UNUSED; |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 601 | mFormatType = FORMAT_NONE; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | void Overlay::PipeBook::destroy() { |
| 605 | if(mPipe) { |
| 606 | delete mPipe; |
| 607 | mPipe = NULL; |
| 608 | } |
| 609 | mDisplay = DPY_UNUSED; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 610 | mMixer = MIXER_UNUSED; |
Baldev Sahu | 979e8f0 | 2014-11-12 15:35:13 +0530 | [diff] [blame] | 611 | mFormatType = FORMAT_NONE; |
Zohaib Alam | 4b0a924 | 2013-11-20 23:54:12 -0500 | [diff] [blame] | 612 | mSession = NONE; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | Overlay* Overlay::sInstance = 0; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 616 | int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1}; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 617 | int Overlay::sDMAMode = DMA_LINE_MODE; |
Raj Kamal | a8c065f | 2013-10-22 14:52:45 +0530 | [diff] [blame] | 618 | bool Overlay::sDMAMultiplexingSupported = false; |
Saurabh Shah | 24eec8a | 2014-08-22 15:07:25 -0700 | [diff] [blame] | 619 | bool Overlay::sDebugPipeLifecycle = false; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 620 | int Overlay::PipeBook::NUM_PIPES = 0; |
| 621 | int Overlay::PipeBook::sPipeUsageBitmap = 0; |
| 622 | int Overlay::PipeBook::sLastUsageBitmap = 0; |
| 623 | int Overlay::PipeBook::sAllocatedBitmap = 0; |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 624 | utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] = |
| 625 | {utils::OV_MDP_PIPE_ANY}; |
Jeykumar Sankaran | 89e23ab | 2015-01-28 15:57:46 -0800 | [diff] [blame] | 626 | int Overlay::PipeBook::pipeMinID[utils::OV_MDP_PIPE_ANY] = {0}; |
| 627 | int Overlay::PipeBook::pipeMaxID[utils::OV_MDP_PIPE_ANY] = {0}; |
Saurabh Shah | b8f58e2 | 2013-09-26 16:20:07 -0700 | [diff] [blame] | 628 | void *Overlay::sLibScaleHandle = NULL; |
Saurabh Shah | eac146b | 2014-05-13 11:36:20 -0700 | [diff] [blame] | 629 | int (*Overlay::sFnProgramScale)(struct mdp_overlay_list *) = NULL; |
Praveena Pachipulusu | 734118a | 2014-12-04 14:53:12 +0530 | [diff] [blame] | 630 | /* Dynamically link ABL library */ |
| 631 | void *Overlay::sLibAblHandle = NULL; |
| 632 | int (*Overlay::sFnppParams)(const struct compute_params *, |
| 633 | struct mdp_overlay_pp_params *) = NULL; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 634 | |
| 635 | }; // namespace overlay |